Waitset on DDSStatus
jc211 opened this issue · 3 comments
Can a waitset be used to wait for a subscribtion_matched event?
Here is how I got it to work:
waitset = Waitset(participant)
waitset.attach(data_reader)
data_reader.set_status_mask(DDSStatus.SubscriptionMatched)
waitset.wait()
Also using a listener at the same time with a WaitSet will not work. Make sure no listeners are attached.
Also using a listener at the same time with a WaitSet will not work. Make sure no listeners are attached.
Correct, at least in practice. In theory it is slightly more complicated, and I figured you might find knowing the background useful.
The behaviour you see is because the spec (1) considers the invocation of the listener the same as reading the status and resetting the flag 1, and (2) requires that the listeners be called before waitsets are triggered. The result is that the status conditions can't be meaningfully combined ...
With multiple conditions in the waitset, there are usually some interleavings where you can return from the waitset before the listener is called for some unrelated reason and so it is best to just avoid combining them.
In short the "avoid this, it doesn't work" is good advice! 🙂
Footnotes
-
I don't quite agree with their reasoning and so the C API has an extension to invoke listeners without affecting the state, but that is of little use to you here. ↩