public abstract class WaitSet extends Object implements DDSObject
Condition
objects has a triggerValue of true or else until
the timeout expires.
WaitSet is not necessarily associated with a single
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:
Condition
objects
(StatusCondition
, ReadCondition
or
QueryCondition
) and attaching them to a
WaitSet.Entity.getStatusChanges()
and then
get<CommunicationStatus>
on the
relevant Entity.Entity.getStatusChanges()
and then
Subscriber.getDataReaders(Collection)
on the relevant Subscriber.Entity.getStatusChanges()
and then
DataReader.read()
/
DataReader.take()
on the
relevant DataReader.DataReader.read(org.omg.dds.sub.DataReader.Selector)
/
DataReader.take(org.omg.dds.sub.DataReader.Selector)
with the DataReader.Selector
wrapping a
ReadCondition or a QueryCondition.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.Constructor and Description |
---|
WaitSet() |
Modifier and Type | Method and Description |
---|---|
abstract void |
attachCondition(Condition cond)
Attaches a Condition to the WaitSet.
|
abstract void |
detachCondition(Condition cond)
Detaches a Condition from the WaitSet.
|
abstract Collection<Condition> |
getConditions()
This operation retrieves the list of attached conditions.
|
static WaitSet |
newWaitSet(ServiceEnvironment env) |
abstract void |
waitForConditions()
This operation allows an application thread to wait for the occurrence
of certain conditions.
|
abstract void |
waitForConditions(Collection<Condition> activeConditions)
This operation allows an application thread to wait for the occurrence
of certain conditions.
|
abstract void |
waitForConditions(Collection<Condition> activeConditions,
Duration timeout)
This operation allows an application thread to wait for the occurrence
of certain conditions.
|
abstract void |
waitForConditions(Collection<Condition> activeConditions,
long timeout,
TimeUnit unit)
This operation allows an application thread to wait for the occurrence
of certain conditions.
|
abstract void |
waitForConditions(Duration timeout)
This operation allows an application thread to wait for the occurrence
of certain conditions.
|
abstract void |
waitForConditions(long timeout,
TimeUnit unit)
This operation allows an application thread to wait for the occurrence
of certain conditions.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEnvironment
public static WaitSet newWaitSet(ServiceEnvironment env)
env
- Identifies the Service instance to which the new
object will belong.public abstract void waitForConditions()
PreconditionNotMetException
.public abstract void waitForConditions(Collection<Condition> activeConditions)
PreconditionNotMetException
.public abstract void waitForConditions(Duration timeout) throws TimeoutException
PreconditionNotMetException
.TimeoutException
- if the timeout argument, which specifies
the maximum duration for the wait, is exceeded and none of
the attached Condition objects is true.public abstract void waitForConditions(long timeout, TimeUnit unit) throws TimeoutException
PreconditionNotMetException
.TimeoutException
- if the timeout argument, which specifies
the maximum duration for the wait, is exceeded and none of
the attached Condition objects is true.public abstract void waitForConditions(Collection<Condition> activeConditions, Duration timeout) throws TimeoutException
PreconditionNotMetException
.TimeoutException
- if the timeout argument, which specifies
the maximum duration for the wait, is exceeded and none of
the attached Condition objects is true.public abstract void waitForConditions(Collection<Condition> activeConditions, long timeout, TimeUnit unit) throws TimeoutException
PreconditionNotMetException
.TimeoutException
- if the timeout argument, which specifies
the maximum duration for the wait, is exceeded and none of
the attached Condition objects is true.public abstract void attachCondition(Condition cond)
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.OutOfResourcesException
- if attaching the condition requires
the allocation of unavailable middleware or OS resources.public abstract void detachCondition(Condition cond)
PreconditionNotMetException
- if the Condition was not
attached to the WaitSet.public abstract Collection<Condition> getConditions()
Copyright © 2014. All rights reserved.