I am using CycloneDDS v0.11.0 and trying to use a waitset to detect when new data is available. Here's how I am setting up my waitset and attaching a read condition:
auto rdcond = dds_create_readcondition(reader, DDS_ALIVE_INSTANCE_STATE | DDS_NOT_READ_SAMPLE_STATE);
dds_waitset_attach(waitSet, rdcond, reader);
I then call dds_waitset_wait in an infinite loop to block until waitset is triggered:
int status = dds_waitset_wait(waitSet, wsresults, wsresultsize, DDS_INFINITY);
According to the CycloneDDS documentation, the function should block until one of the attached entities is triggered or the timeout (DDS_INFINITY in my case) elapses.
However, instead of waiting for new data, the function returns immediately with status = 0. The documentation states the following about return values:
Since dds_waitset_wait is returning 0, it seems to indicate a timeout, but I specified DDS_INFINITY, so I was expecting it to block indefinitely until new data arrived.
Why is dds_waitset_wait not blocking as expected? Am I missing something in my setup, or is there a known issue with this approach?
There are no known issues with this. My guess is that you are not doing something that would make the wait set stop triggering.
For example, this read condition triggers whenever there is unread (and "alive") data in the reader. If you don't read what's present, it'll keep triggering forever.