I have some code that waits on a WaitSet in a loop, looking for DDS data, and dispatching to a handler function when it gets it.
dds::core::cond::WaitSet waitSet; dds::sub::cond::ReadCondition readCondition(commandReader_, dds::sub::status::DataState::any(), std::bind(&ReceiverNode::handleCommands, this)); waitSet += readCondition; waitSet += guardCondition_; while (!isShuttingDown()) { try { waitSet.dispatch(); } catch...
It is able to use this waitset to detect incoming DDS data, and it responds by successfully sending a DDS packet.
However, when it returns to wait for the waitset, it gets a PreconditionNotMetError exception, with the string "Invalid data" in the what() call.
This would seem to be catastrophic, something went terribly wrong, right? Except when it returns to wait at the WaitSet, everything is fine, and it gets the next piece of data.
The documentation suggests that this error could be happening if more than one thread is waiting on a waitset. But this does not appear to the case.
Again, the order is:l
listenForCommands: Waiting on waitSet
listenForCommands: Back from waiting on waitSet
listenForCommands: Waiting on waitSet
listenForCommands: PreconditionNotMetError while waiting for waitset
listenForCommands: Exception info: Invalid data
listenForCommands: Waiting on waitSet
I should add the following notes: