Hi, currently i am exploring a few options to retrieve data from the datareader.
I am looking at using Waitset with infinite timeout.
As i will have a lot of datareaders, therefore i will have a lot of threads using the Waitset to wait for data.
1) Can i find out when i use Waitset wait() with infinite timeout, is the thread put to sleep?
2) Will there still be any CPU utilization during the wait(), as in will the thread wakes up periodically to check if the Status Condition is triggered?
Thanks.
So to your questions, yes, when a thread calls waitset->wait() with infinite timeout, the thread will be blocked until the conditions for which the waitset is triggered becomes true. e.g., new data.
While blocked by the waitset, the thread is not using any CPU. Of course, there are DDS-internal threads that are running to check for the periodically triggered status conditions (if enabled) and arriving data in sockets, which then would make calls to wake up the thread on the waitset.
NOTE, a waitset can wait for any number of Status and other Conditions. If you wait for multiple conditions, the first thing that you have to do is determine which condition woke up the waitset in order to process the correct item, e.g., you can block a thread to be woken up when data arrives for a number of different DataReaders.
But to do so, when the thread unblocks, it needs to check the status conditions of which DataReaders woke it up (could be more than 1, a sequence of active/triggered status conditions is returned by the waitset) so that it processes the data from the DataReaders that received data.
To add to Howard recommendation, I would suggest if there are multiple datareaders and data reception rate for a particular reader is too high. It can cause delay in reception of data from other DR.
In that case, for DR with high data reception rate, you can have separate Waitset for it and other waitset for all other DRs