21 package org.opensplice.dds.core;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.concurrent.ConcurrentHashMap;
26 import java.util.concurrent.TimeUnit;
27 import java.util.concurrent.TimeoutException;
36 private final DDS.WaitSet oldWaitSet;
40 this.environment = environment;
41 this.oldWaitSet =
new DDS.WaitSet();
47 return this.environment;
52 DDS.ConditionSeqHolder holder =
new DDS.ConditionSeqHolder();
53 int rc = this.oldWaitSet._wait(holder, DDS.DURATION_INFINITE.value);
56 "Waitset.waitForConditions() failed.");
63 if (activeConditions == null) {
65 "Illegal Collection<Condition> (null) provided.");
68 DDS.ConditionSeqHolder holder =
new DDS.ConditionSeqHolder();
69 int rc = this.oldWaitSet._wait(holder, DDS.DURATION_INFINITE.value);
72 "Waitset.waitForConditions() failed.");
74 activeConditions.clear();
76 for (DDS.Condition cond : holder.value) {
77 activeConditions.add(this.conditions.get(cond));
83 if (timeout == null) {
85 "Illegal Duration (null) provided.");
87 DDS.ConditionSeqHolder holder =
new DDS.ConditionSeqHolder();
89 .
convert(this.environment, timeout);
91 int rc = this.oldWaitSet._wait(holder, oldTimeout);
94 "Waitset.waitForConditions() failed.");
99 throws TimeoutException {
106 Duration timeout)
throws TimeoutException {
108 if (activeConditions == null) {
110 "Illegal Collection<Condition> (null) provided.");
113 DDS.ConditionSeqHolder holder =
new DDS.ConditionSeqHolder();
115 .
convert(this.environment, timeout);
117 int rc = this.oldWaitSet._wait(holder, oldTimeout);
120 "Waitset.waitForConditions() failed.");
122 activeConditions.clear();
124 for (DDS.Condition cond : holder.value) {
125 activeConditions.add(this.conditions.get(cond));
132 long timeout, TimeUnit unit)
throws TimeoutException {
144 "Illegal Condition (null) provided.");
148 }
catch (ClassCastException cce) {
150 "Attaching non-OpenSplice Condition implementation is not supported.");
152 DDS.Condition old = c.getOldCondition();
153 int rc = this.oldWaitSet.attach_condition(old);
155 "Attaching condition failed.");
157 this.conditions.put(old, cond);
167 "Illegal Condition (null) provided.");
171 }
catch (ClassCastException cce) {
173 "Detaching non-OpenSplice Condition implementation is not supported.");
175 DDS.Condition old = c.getOldCondition();
176 int rc = this.oldWaitSet.detach_condition(old);
178 "Detaching condition failed.");
180 this.conditions.remove(old);
186 return Collections.unmodifiableCollection(conditions.values());
191 return "WaitSet (" + Integer.toHexString(this.hashCode()) +
")";
static void checkReturnCodeWithTimeout(int retCode, OsplServiceEnvironment environment, String message)
WaitSetImpl(OsplServiceEnvironment environment)
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.
static DDS.Duration_t convert(OsplServiceEnvironment environment, Duration d)
ServiceEnvironment getEnvironment()
void waitForConditions(Duration timeout)
A Condition is a root interface for all the conditions that may be attached to a org.omg.dds.core.WaitSet.
void attachCondition(Condition cond)
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
ServiceProviderInterface getSPI()
void waitForConditions(Collection< Condition > activeConditions, Duration timeout)
void waitForConditions(Collection< Condition > activeConditions)
Duration newDuration(long duration, TimeUnit unit)
Construct a org.omg.dds.core.Duration of the given magnitude.
A span of elapsed time expressed with nanosecond precision.
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
Collection< Condition > getConditions()
void detachCondition(Condition cond)
void waitForConditions(Collection< Condition > activeConditions, long timeout, TimeUnit unit)
void waitForConditions(long timeout, TimeUnit unit)