Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix late joiners example #2096

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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