OpenSplice C# API  v6.x
OpenSplice C# Data Distribution Service Data-Centric Publish-Subscribe API
DDS.IWaitSet Interface Reference

An IWaitSet object allows an application to wait until one or more of the attached ICondition objects evaluates to true or until the timeout expires. More...

Collaboration diagram for DDS.IWaitSet:
Collaboration graph

Public Member Functions

ReturnCode AttachCondition (ICondition condition)
 This operation attaches a condition to the WaitSet. More...
 
ReturnCode DetachCondition (ICondition condition)
 This operation detaches an ICondition from the IWaitSet. More...
 
ReturnCode GetConditions (ref ICondition[] attachedConditions)
 This operation retrieves the list of attached conditions. More...
 
ReturnCode Wait (ref ICondition[] activeConditions, Duration timeout)
 This operation allows an application thread to wait for the occurrence of at least one of the conditions that is attached to the IWaitSet. More...
 

Detailed Description

An IWaitSet object allows an application to wait until one or more of the attached ICondition objects evaluates to true or until the timeout expires.

The IWaitSet has no factory and must be created by the application. It is directly created as an object by using the WaitSet constructor.

See also
Waitset
/* Simplified example of the use of an WaitSet
* Defaults are used and possible errors are ignored. */
/* Prepare Domain. */
DDS.IDomainParticipant participant = factory.CreateParticipant(DDS.DomainId.Default);
/* Create waitset */
IWaitSet waitset = new WaitSet();
/* Add topic data type to the system. */
DDS.ITypeSupport typesupport = new Space.FooTypeSupport();
DDS.ReturnCode retcode = typesupport.RegisterType(participant, "Space.Foo");
DDS.ITopic topic = participant.CreateTopic("SpaceFooTopic", "Space.Foo");
/* Create typed datareader. */
DDS.ISubscriber subscriber = participant.CreateSubscriber();
Space.FooDataReader reader = (Space.FooDataReader)publisher.CreateDataReader(topic);
/* Create querycondition */
string[] params = new string[1];
params[0] = "1";
IQueryCondition condition = reader.CreateQueryCondition("field = %0", params);
/* Attach condition to waitset */
retcode = waitset.AttachCondition(condition);
/* Wait for the condition to be triggered or a timeout occurs */
Space.Foo[] samples = null;
DDS.SampleInfo[] infos = null;
DDS.ICondition[] conditions = new DDS.ICondition[1];
retcode = waitset.Wait(ref conditions, new DDS.Duration(3, 0));
if (retcode == DDS.ReturnCode.Ok) {
retcode = reader.ReadWithCondition(ref samples, ref infos, DDS.Length.Unlimited, condition);
...
}
...

Definition at line 104 of file DdsDcpsInterfaces.cs.

Member Function Documentation

◆ AttachCondition()

ReturnCode DDS.IWaitSet.AttachCondition ( ICondition  condition)

This operation attaches a condition to the WaitSet.

This operation attaches an ICondition to the WaitSet. The parameter condition must be either an IReadCondition, IQueryCondition, IStatusCondition or IGuardCondition. To get this parameter see:

When an IGuardCondition is initially created, the TriggerValue is false. When an ICondition, whose TriggerValue evaluates to true, is attached to an IWaitSet that is currently being waited on (using the Wait operation), the IWaitSet will unblock immediately.

Parameters
conditionThe condition to be attached to the IWaitSet. The parameter must be either an IReadCondition, IQueryCondition, IStatusCondition or IGuardCondition
Returns
Possible return codes are:

◆ DetachCondition()

ReturnCode DDS.IWaitSet.DetachCondition ( ICondition  condition)

This operation detaches an ICondition from the IWaitSet.

If the ICondition was not attached to this IWaitSet, the operation returns PreconditionNotMet.

Parameters
conditionThe attached condition in the IWaitSet which is to be detached.
Returns
Possible return codes are:

◆ GetConditions()

ReturnCode DDS.IWaitSet.GetConditions ( ref ICondition []  attachedConditions)

This operation retrieves the list of attached conditions.

This operation retrieves the list of attached conditions in the IWaitSet. The parameter attachedConditions is a reference to a sequence which afterwards will refer to the sequence of attached conditions. The resulting sequence will either be an empty sequence, meaning there were no conditions attached, or will contain a list of IReadCondition, IQueryCondition, IStatusCondition and IGuardCondition. These conditions previously have been attached by AttachCondition and were created by there respective create operation:

Parameters
attachedConditionsA reference to a sequence that will hold all the attached conditions on the IWaitSet
Returns
Possible return codes are:

◆ Wait()

ReturnCode DDS.IWaitSet.Wait ( ref ICondition []  activeConditions,
Duration  timeout 
)

This operation allows an application thread to wait for the occurrence of at least one of the conditions that is attached to the IWaitSet.

This operation allows an application thread to wait for the occurrence of at least one of the conditions to evaluate to true that is attached to the WaitSet. If all of the conditions attached to the WaitSet have a TriggerValue of false, the wait operation will block the calling thread. The result of the operation is the continuation of the application thread after which the result is left in activeConditions. This is a reference to a sequence, which will contain the list of all the attached conditions that have a TriggerValue of true.

The parameter timeout specifies the maximum duration for the wait to block the calling application thread (when none of the attached conditions has a TriggerValue of true). In that case the return value is Timeout and the activeConditions sequence is left empty. Since it is not allowed for more than one application thread to be waiting on the same WaitSet, the operation returns immediately with the value PreconditionNotMet when the wait operation is invoked on a WaitSet which already has an application thread blocking on it.

Parameters
activeConditionsA sequence which is used to pass the list of all the attached conditions that have a TriggerValue of true.
timeoutThe maximum duration to block for the wait, after which the application thread is unblocked. The special constant Infinite can be used when the maximum waiting time does not need to be bounded.
Returns
Possible return codes for the operation are:
  • DDS.ReturnCode Ok - At least one of the attached conditions has a TriggerValue of true.
  • DDS.ReturnCode Error - An internal error has occurred.
  • DDS.ReturnCode OutOfResources - The Data Distribution Service ran out of resources to complete this operation.
  • DDS.ReturnCode Timeout - The timeout has elapsed without any of the attached conditions becoming true.
  • DDS.ReturnCode PreconditionNotMet - the WaitSet already has an application thread blocking on it.

The documentation for this interface was generated from the following file: