The wait_for_historical_data() operation waits (blocks) until all "historical" data is received from matched DataWriters. "Historical" data means DDS samples that were written before the DataReader joined the DDS domain.
This operation is intended only for DataReaders that have:
Calling wait_for_historical_data() on a non-reliable DataReader will always return immediately, since Connext DDS will never deliver historical data to non-reliable DataReaders.
As soon as an application enables a non-VOLATILE DataReader, it will start receiving both "historical" data as well as any new data written by matching DataWriters. If you want the subscribing application to wait until all "historical" data is received, use this operation:
DDS_ReturnCode_t wait_for_historical_data (const DDS_Duration_t & max_wait)
The wait_for_historical_data() operation blocks the calling thread until either all "historical" data is received or the duration specified by the max_wait parameter elapses, whichever happens first. A return value of OK indicates that all the "historical" data was received; a return value of TIMEOUT indicates that max_wait elapsed before all the data was received.
wait_for_historical_data() will return immediately if no DataWriters have been discovered at the time the operation is called. Therefore it is advisable to make sure at least one DataWriter has been discovered before calling this operation; one way to do this is to use get_subscription_matched_status(), like this:
while (1) { DDS_SubscriptionMatchedStatus status; MyType_reader->get_subscription_matched_status(status); if (status.current_count > 0) { break; } NDDSUtility::sleep(sleep_period); }
© 2015 RTI