![]() |
OpenSplice Java 5 DCPS
v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
|
A WaitSet object allows an application to wait until one or more of the attached org.omg.dds.core.Condition objects has a triggerValue of true or else until the timeout expires. More...
Public Member Functions | |
abstract void | attachCondition (Condition cond) |
This operation attaches a Condition to the WaitSet. More... | |
abstract void | detachCondition (Condition cond) |
Detaches a Condition from the WaitSet. More... | |
abstract Collection< Condition > | getConditions () |
This operation retrieves the list of attached conditions. More... | |
ServiceEnvironment | getEnvironment () |
abstract void | waitForConditions () |
This operation allows an application thread to wait for the occurrence of a certain condition. More... | |
abstract void | waitForConditions (Collection< Condition > activeConditions) |
This operation allows an application thread to wait for the occurrence of certain conditions. More... | |
abstract void | waitForConditions (Duration timeout) throws TimeoutException |
This operation allows an application thread to wait for the occurrence of certain conditions. More... | |
abstract void | waitForConditions (long timeout, TimeUnit unit) throws TimeoutException |
This operation allows an application thread to wait for the occurrence of certain conditions. More... | |
abstract void | waitForConditions (Collection< Condition > activeConditions, Duration timeout) throws TimeoutException |
This operation allows an application thread to wait for the occurrence of certain conditions. More... | |
abstract void | waitForConditions (Collection< Condition > activeConditions, long timeout, TimeUnit unit) throws TimeoutException |
This operation allows an application thread to wait for the occurrence of certain conditions. More... | |
Static Public Member Functions | |
static WaitSet | newWaitSet (ServiceEnvironment env) |
Creates a new WaitSet object to be used in the application. More... | |
A WaitSet object allows an application to wait until one or more of the attached org.omg.dds.core.Condition objects has a triggerValue of true or else until the timeout expires.
WaitSet is not necessarily associated with a single org.omg.dds.domain.DomainParticipant and could be used to wait on Condition objects associated with different DomainParticipant objects.
This mechanism is wait-based. Its general use pattern is as follows:
get<CommunicationStatus>
on the relevant Entity. Usually the first step is done in an initialization phase, while the others are put in the application main loop.
As there is no extra information passed from the middleware to the application when a wait returns (only the list of triggered Condition objects), Condition objects are meant to embed all that is needed to react properly when enabled. In particular, Entity-related conditions are related to exactly one Entity and cannot be shared.
The blocking behavior of the WaitSet is described below. The result of a waitForConditions() operation depends on the state of the WaitSet, which in turn depends on whether at least one attached Condition has a triggerValue of true. If the waitForConditions() operation is called on WaitSet that is blocked, it will block the calling thread. If waitForConditions() is called on a WaitSet that is unblocked, it will return immediately. In addition, when the WaitSet transitions from BLOCKED to UNBLOCKED it wakes up any threads that had called waitForConditions() on it.
Similar to the invocation of listeners, there is no implied "event queuing" in the awakening of a WaitSet in the sense that, if several Conditions attached to the WaitSet have their triggerValue transition to true in sequence the DCPS implementation needs to only unblock the WaitSet once.
Example
// Instantiate a WaitSet.
WaitSet w = WaitSet.newWaitSet(env);
// Obtain a StatusCondition from a DataReader
StatusCondition<DataReader<Foo>> statusCond = dataReader.getStatusCondition();
// Select the status you are interested in.
statusCond.setEnabledStatuses(InconsistentTopicStatus.class);
// Attach the StatusCondition to the WaitSet.
w.attachCondition(statusCond);
Duration waitTimeout = Duration.newDuration(60, TimeUnit.SECONDS, env);
// Wait for the status to trigger.
try
{
w.waitForConditions(waitTimeout);
}
catch (TimeoutException e) {
}
Definition at line 117 of file WaitSet.java.
|
abstract |
This operation attaches a Condition to the WaitSet.
The parameter cond must be either a ReadCondition, QueryCondition, StatusCondition or GuardCondition. To get this parameter see:
When a GuardCondition is initially created, the triggerValue is false.
It is possible to attach a Condition on a WaitSet that is currently being waited upon (via the waitForConditions() operation). In this case, if the Condition has a triggerValue of true, then attaching the condition will unblock the WaitSet.
Adding a Condition that is already attached to the WaitSet has no effect.
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
|
abstract |
Detaches a Condition from the WaitSet.
PreconditionNotMetException | if the Condition was not attached to the WaitSet. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
|
abstract |
This operation retrieves the list of attached conditions.
The list can contain the following conditions:
ReadCondition, QueryCondition, StatusCondition or GuardCondition.
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
|
inherited |
Implemented in org.omg.dds.core.ServiceEnvironment, org.opensplice.dds.sub.ReflectionDataReader< TYPE, OUT_TYPE >, org.opensplice.dds.core.ModifiableTimeImpl, org.opensplice.dds.pub.ReflectionDataWriter< TYPE >, org.opensplice.dds.core.DurationImpl, org.opensplice.dds.topic.ContentFilteredTopicImpl< TYPE >, org.opensplice.dds.sub.ReadConditionImpl< TYPE >, org.opensplice.dds.core.EntityQosImpl< T extends QosPolicy >, org.opensplice.dds.type.TypeSupportImpl< TYPE >, org.opensplice.dds.topic.PublicationBuiltinTopicDataImpl, org.opensplice.dds.topic.SubscriptionBuiltinTopicDataImpl, org.opensplice.dds.topic.TopicBuiltinTopicDataImpl, org.opensplice.dds.domain.DomainParticipantFactoryImpl, org.opensplice.dds.core.QosProviderImpl, org.opensplice.dds.core.status.OfferedIncompatibleQosStatusImpl, org.opensplice.dds.core.status.RequestedIncompatibleQosStatusImpl, org.opensplice.dds.core.InstanceHandleImpl, org.opensplice.dds.core.StatusConditionImpl< T extends Entity<?, ?>, org.opensplice.dds.core.status.LivelinessChangedStatusImpl, org.opensplice.dds.core.status.PublicationMatchedStatusImpl, org.opensplice.dds.core.status.SubscriptionMatchedStatusImpl, org.opensplice.dds.sub.SampleImpl< TYPE >, org.opensplice.dds.core.policy.ShareImpl, org.opensplice.dds.core.status.OfferedDeadlineMissedStatusImpl, org.opensplice.dds.core.status.SampleRejectedStatusImpl, org.opensplice.dds.core.WaitSetImpl, org.opensplice.dds.topic.ParticipantBuiltinTopicDataImpl, org.opensplice.dds.core.status.RequestedDeadlineMissedStatusImpl, org.opensplice.dds.topic.BuiltinTopicKeyImpl, org.opensplice.dds.core.GuardConditionImpl, org.opensplice.dds.core.event.AllDataDisposedEventImpl< TYPE >, org.opensplice.dds.core.policy.QosPolicyCountImpl, org.opensplice.dds.core.status.InconsistentTopicStatusImpl, org.opensplice.dds.core.status.LivelinessLostStatusImpl, org.opensplice.dds.core.status.SampleLostStatusImpl, org.opensplice.dds.core.policy.QosPolicyImpl, org.opensplice.dds.core.status.AllDataDisposedStatusImpl, org.opensplice.dds.core.IllegalArgumentExceptionImpl, org.opensplice.dds.core.InconsistentPolicyExceptionImpl, org.opensplice.dds.core.policy.PolicyFactoryImpl, org.opensplice.dds.core.policy.TypeConsistencyEnforcementImpl, org.opensplice.dds.core.PreconditionNotMetExceptionImpl, org.opensplice.dds.core.AlreadyClosedExceptionImpl, org.opensplice.dds.core.IllegalOperationExceptionImpl, org.opensplice.dds.core.ImmutablePolicyExceptionImpl, org.opensplice.dds.core.NotEnabledExceptionImpl, org.opensplice.dds.core.OutOfResourcesExceptionImpl, org.opensplice.dds.core.DDSExceptionImpl, org.opensplice.dds.core.status.DataAvailableStatusImpl, and org.opensplice.dds.core.status.DataOnReadersStatusImpl.
|
static |
Creates a new WaitSet object to be used in the application.
env | Identifies the Service instance to which the new object will belong. |
Definition at line 127 of file WaitSet.java.
|
abstract |
This operation allows an application thread to wait for the occurrence of a certain condition.
If the condition attached to the WaitSet does not a triggerValue of true, the operation will block suspending the calling thread.
The operation will unblock when the attached condition has a triggerValue of true.
It is not allowed for more than one application thread to be waiting on the same WaitSet. If the operation is invoked on a WaitSet that already has a thread blocking on it, the operation will fail with the value org.omg.dds.core.PreconditionNotMetException.
org.omg.dds.core.PreconditionNotMetException | The WaitSet already has an application thread blocking on it. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
|
abstract |
This operation allows an application thread to wait for the occurrence of certain conditions.
If none of the conditions attached to the WaitSet have a triggerValue of true, the operation will block suspending the calling thread.
The result of the wait operation is the list of all the attached conditions that have a triggerValue of true (i.e., the conditions that unblocked the wait).
It is not allowed for more than one application thread to be waiting on the same WaitSet. If the operation is invoked on a WaitSet that already has a thread blocking on it, the operation will fail with the value org.omg.dds.core.PreconditionNotMetException.
activeConditions | a collection where the triggered conditions are stored in. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
org.omg.dds.core.PreconditionNotMetException | The WaitSet already has an application thread blocking on it. |
|
abstract |
This operation allows an application thread to wait for the occurrence of certain conditions.
If none of the conditions attached to the WaitSet have a triggerValue of true, the operation will block suspending the calling thread.
The operation will unblock when the attached condition has a triggerValue of true or when the timeout period has elapsed a TimeoutException occurs.
It is not allowed for more than one application thread to be waiting on the same WaitSet. If the operation is invoked on a WaitSet that already has a thread blocking on it, the operation will fail with the value org.omg.dds.core.PreconditionNotMetException.
timeout | The maximum duration to block for the wait, after which the application thread is unblocked. |
TimeoutException | if the timeout argument, which specifies the maximum duration for the wait, is exceeded and none of the attached Condition objects is true. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
org.omg.dds.core.PreconditionNotMetException | The WaitSet already has an application thread blocking on it. |
|
abstract |
This operation allows an application thread to wait for the occurrence of certain conditions.
If none of the conditions attached to the WaitSet have a triggerValue of true, the operation will block suspending the calling thread.
The operation will unblock when the attached condition has a triggerValue of true or when the timeout period has elapsed a TimeoutException occurs.
It is not allowed for more than one application thread to be waiting on the same WaitSet. If the operation is invoked on a WaitSet that already has a thread blocking on it, the operation will fail with the value org.omg.dds.core.PreconditionNotMetException.
timeout | The maximum duration to block for the wait, after which the application thread is unblocked. |
unit | The TimeUnit which the timeout describes (i.e. TimeUnit.SECONDS or TimeUnit.MILLISECONDS) |
TimeoutException | if the timeout argument, which specifies the maximum duration for the wait, is exceeded and none of the attached Condition objects is true. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
org.omg.dds.core.PreconditionNotMetException | The WaitSet already has an application thread blocking on it. |
|
abstract |
This operation allows an application thread to wait for the occurrence of certain conditions.
If none of the conditions attached to the WaitSet have a triggerValue of true, the operation will block suspending the calling thread.
The result of the wait operation is the list of all the attached conditions that have a triggerValue of true (i.e., the conditions that unblocked the wait).
It is not allowed for more than one application thread to be waiting on the same WaitSet. If the operation is invoked on a WaitSet that already has a thread blocking on it, the operation will fail with the value org.omg.dds.core.PreconditionNotMetException.
activeConditions | a collection where the triggered conditions are stored in. |
timeout | The maximum duration to block for the wait, after which the application thread is unblocked. |
TimeoutException | if the timeout argument, which specifies the maximum duration for the wait, is exceeded and none of the attached Condition objects is true. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
org.omg.dds.core.PreconditionNotMetException | The WaitSet already has an application thread blocking on it. |
|
abstract |
This operation allows an application thread to wait for the occurrence of certain conditions.
If none of the conditions attached to the WaitSet have a triggerValue of true, the operation will block suspending the calling thread.
The result of the wait operation is the list of all the attached conditions that have a triggerValue of true (i.e., the conditions that unblocked the wait).
It is not allowed for more than one application thread to be waiting on the same WaitSet. If the operation is invoked on a WaitSet that already has a thread blocking on it, the operation will fail with the value org.omg.dds.core.PreconditionNotMetException.
activeConditions | a collection where the triggered conditions are stored in. |
timeout | The maximum duration to block for the wait, after which the application thread is unblocked. |
unit | The TimeUnit which the timeout describes (i.e. TimeUnit.SECONDS or TimeUnit.MILLISECONDS) |
TimeoutException | if the timeout argument, which specifies the maximum duration for the wait, is exceeded and none of the attached Condition objects is true. |
org.omg.dds.core.DDSException | An internal error has occurred. |
org.omg.dds.core.OutOfResourcesException | The Data Distribution Service ran out of resources to complete this operation. |
org.omg.dds.core.PreconditionNotMetException | The WaitSet already has an application thread blocking on it. |