Using WaitSets and Conditions.
More...
Using WaitSets and Conditions.
The following #includes are needed for the examples on this page
#include <iostream>
#include <dds/core/ddscore.hpp>
#include <dds/sub/ddssub.hpp>
Setting up a WaitSet
- Create a WaitSet and attach Conditions
waitset += guard_cond;
waitset += status_cond;
Waiting for Condition(s) to trigger
You have two ways to wait for Conditions to trigger: wait or dispatch.
- Wait example
for (uint32_t i = 0; i < active_conditions.size(); i++) {
if (active_conditions[i] == guard_cond) {
std::cout << "guard_cond was triggered\n";
} else if (active_conditions[i] == status_cond) {
std::cout << "status_cond was triggered\n";
}
}
- Dispatch example
std::cout << "read_cond1 was triggered\n";
});
ReadCondition read_cond2(
reader2,
[](Condition c) {
auto reader = rc.data_reader();
std::cout << "read_cond2 was triggered (topic is "
});
waitset += read_cond1;
waitset += read_cond2;
- See also
- Filtering with Query Conditions