CoreDX DDS Modern C++ API
Public Member Functions | List of all members
dds::core::cond::WaitSet Class Reference

A WaitSet object allows an application to wait until one or more of the attached Condition objects has a trigger_value of TRUE or else until the timeout expires. More...

Inheritance diagram for dds::core::cond::WaitSet:
Inheritance graph
[legend]
Collaboration diagram for dds::core::cond::WaitSet:
Collaboration graph
[legend]

Public Member Functions

 WaitSet ()
 Creates a new waitset.
 
const ConditionSeq wait (const dds::core::Duration &timeout)
 This operation allows an application thread to wait for the occurrence of certain conditions. More...
 
const ConditionSeq wait ()
 This operation allows an application thread to wait for the occurrence of certain conditions. More...
 
ConditionSeq & wait (ConditionSeq &triggered, const dds::core::Duration &timeout)
 This operation allows an application thread to wait for the occurrence of certain conditions. More...
 
ConditionSeq & wait (ConditionSeq &triggered)
 This operation allows an application thread to wait for the occurrence of certain conditions. More...
 
void dispatch ()
 Waits for at least one of the attached conditions to trigger and then dispatches the events.
 
void dispatch (const dds::core::Duration &timeout)
 Waits for at least one of the attached conditions to trigger and then dispatches the events, or, times out and unblocks.
 
WaitSetoperator+= (const dds::core::cond::Condition &cond)
 A synonym for attach_condition.
 
WaitSetoperator-= (const dds::core::cond::Condition &cond)
 A synonym for detach_condition.
 
WaitSetattach_condition (const dds::core::cond::Condition &cond)
 Attaches a Condition to the WaitSet. More...
 
bool detach_condition (const dds::core::cond::Condition &cond)
 Detaches a Condition from the WaitSet. More...
 
const ConditionSeq conditions () const
 This operation retrieves the list of attached conditions. More...
 
ConditionSeq & conditions (ConditionSeq &conds) const
 This operation retrieves the list of attached conditions. More...
 
- Public Member Functions inherited from dds::core::Reference< DELEGATE >
 Reference (dds::core::null_type &)
 Creates a "null" reference.
 
 Reference (const Reference &ref)
 Creates a reference from another. More...
 
template<typename D >
 Reference (const Reference< D > &ref)
 Enables safe assignment from other reference types. More...
 
 Reference (DELEGATE_T *p)
 The following two constructors create a dds Reference from a vendor specific delegate. More...
 
 ~Reference ()
 Destroys a reference.
 
template<typename R >
bool operator== (const R &ref) const
 Compares two reference objects and returns true if they are equal. More...
 
template<typename R >
bool operator!= (const R &ref) const
 Compares two reference objects and returns true if they are not-equal. More...
 
Referenceoperator= (const null_type)
 Special assignment operators that takes care of assigning null to this reference. More...
 
bool is_nil () const
 Returns true if this reference object is nil, meaning pointing to null.
 
bool operator== (const null_type) const
 Special operator== used to check if this reference object equals the null reference. More...
 
bool operator!= (const null_type nil) const
 Special operator!= used to check if this reference object does not equals the null reference. More...
 
const DELEGATE_REF_T & delegate () const
 Returns a reference to the underlying delegate. More...
 
DELEGATE_REF_T & delegate ()
 Returns a reference to the underlying delegate. More...
 
DELEGATE * operator-> ()
 The operator->() is provided to be able to directly invoke methods on the delegate. More...
 
const DELEGATE * operator-> () const
 The operator->() is provided to be able to directly invoke methods on the delegate. More...
 

Detailed Description

A WaitSet object allows an application to wait until one or more of the attached Condition objects has a trigger_value of TRUE or else until the timeout expires.

A WaitSet is not necessarily associated with a single DomainParticipant and could be used to wait on Condition objects associated with different DomainParticipant objects.

Member Function Documentation

◆ attach_condition()

WaitSet& dds::core::cond::WaitSet::attach_condition ( const dds::core::cond::Condition cond)

Attaches a Condition to the WaitSet.

It is possible to attach a Condition on a WaitSet that is currently being waited upon (via the wait operation). In this case, if the Condition has a trigger_value of TRUE, then attaching the condition will unblock the WaitSet. Adding a Condition that is already attached to the WaitSet has no effect.

Parameters
condthe condition to be attached to this waitset.

◆ conditions() [1/2]

const ConditionSeq dds::core::cond::WaitSet::conditions ( ) const

This operation retrieves the list of attached conditions.

Returns
the list of attached conditions.

◆ conditions() [2/2]

ConditionSeq& dds::core::cond::WaitSet::conditions ( ConditionSeq &  conds) const

This operation retrieves the list of attached conditions.

Returns
the list of attached conditions.

◆ detach_condition()

bool dds::core::cond::WaitSet::detach_condition ( const dds::core::cond::Condition cond)

Detaches a Condition from the WaitSet.

If the Condition was not attached to the WaitSet, the operation will return false.

Parameters
condthe condition to detach from this WaitSet
Returns
true if the condition was found and detached, false if the condition was not part of the WaitSet.

◆ wait() [1/4]

const ConditionSeq dds::core::cond::WaitSet::wait ( const dds::core::Duration timeout)

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 trigger_value of TRUE, the wait operation will block suspending the calling thread.

The wait operation takes a timeout argument that specifies the maximum duration for the wait. It this duration is exceeded and none of the attached Condition objects is true, wait will continue and the returned ConditionSeq will be empty.

It is not allowed for more than one application thread to be waiting on the same WaitSet. If the wait operation is invoked on a WaitSet that already has a thread blocking on it, the operation will raise immediately an exception PreconditionNotMet.

The result of the wait operation is the list of all the attached conditions that have a trigger_value of TRUE (i.e., the conditions that unblocked the wait).

Parameters
timeoutthe maximum amount of time for which the wait should block while waiting for a condition to be triggered.
Returns
a vector containing the triggered conditions

◆ wait() [2/4]

const ConditionSeq dds::core::cond::WaitSet::wait ( )

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 trigger_value of TRUE, the wait operation will block suspending the calling thread.

It is not allowed for more than one application thread to be waiting on the same WaitSet. If the wait operation is invoked on a WaitSet that already has a thread blocking on it, the operation will raise immediately an exception PreconditionNotMet.

The result of the wait operation is the list of all the attached conditions that have a trigger_value of TRUE (i.e., the conditions that unblocked the wait).

Returns
a vector containing the triggered conditions

◆ wait() [3/4]

ConditionSeq& dds::core::cond::WaitSet::wait ( ConditionSeq &  triggered,
const dds::core::Duration timeout 
)

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 trigger_value of TRUE, the wait operation will block suspending the calling thread.

The wait operation takes a timeout argument that specifies the maximum duration for the wait. It this duration is exceeded and none of the attached Condition objects is true, wait will continue and the returned ConditionSeq will be empty.

It is not allowed for more than one application thread to be waiting on the same WaitSet. If the wait operation is invoked on a WaitSet that already has a thread blocking on it, the operation will raise immediately an exception PreconditionNotMet.

The result of the wait operation is the list of all the attached conditions that have a trigger_value of TRUE (i.e., the conditions that unblocked the wait).

Parameters
triggereda sequence that is populated with triggered conditions on return
timeoutthe maximum amount of time for which the wait should block while waiting for a condition to be triggered.
Returns
a vector containing the triggered conditions

◆ wait() [4/4]

ConditionSeq& dds::core::cond::WaitSet::wait ( ConditionSeq &  triggered)

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 trigger_value of TRUE, the wait operation will block suspending the calling thread.

The wait operation takes a timeout argument that specifies the maximum duration for the wait. It this duration is exceeded and none of the attached Condition objects is true, wait will continue and the returned ConditionSeq will be empty.

It is not allowed for more than one application thread to be waiting on the same WaitSet. If the wait operation is invoked on a WaitSet that already has a thread blocking on it, the operation will raise immediately an exception PreconditionNotMet.

The result of the wait operation is the list of all the attached conditions that have a trigger_value of TRUE (i.e., the conditions that unblocked the wait).

Parameters
triggereda sequence that is populated with triggered conditions on return
Returns
a vector containing the triggered conditions

© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.