Skip to content

Commit

Permalink
Wait for reader to match before sending second round of samples (#2096)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany authored Jul 27, 2021
1 parent 817007d commit d2aa2db
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/C++/DDS/LateJoiners/latejoiners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ void latejoiners()
return;
}

// Wait for volatile reader to match with writer, otherwise it may consider the new samples as historical
std::vector<InstanceHandle_t> matched_writers;
while (ReturnCode_t::RETCODE_OK == myReader2->get_matched_publications(matched_writers) &&
matched_writers.empty() )
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

//Send 20 samples
std::cout << "Publishing 20 samples on the topic..." << std::endl;
for (uint8_t j = 0; j < 20; j++)
Expand Down

0 comments on commit d2aa2db

Please sign in to comment.