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 ds_test hang - remove unsafe condition_variable #5119

Merged
merged 4 commits into from
Mar 17, 2023
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
9 changes: 0 additions & 9 deletions src/ds/test/thread_messaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,12 @@ TEST_CASE("Unique thread IDs" * doctest::test_suite("threadmessaging"))
REQUIRE(main_thread_id == threading::MAIN_THREAD_ID);
assigned_ids.push_back(main_thread_id);

std::mutex all_done_lock;
std::condition_variable all_done;

auto fn = [&]() {
{
std::lock_guard<std::mutex> guard(assigned_ids_lock);
const auto current_thread_id = threading::get_current_thread_id();
assigned_ids.push_back(current_thread_id);
}

{
std::unique_lock lock(all_done_lock);
all_done.wait(lock);
}
};

constexpr size_t num_threads = 20;
Expand All @@ -194,7 +186,6 @@ TEST_CASE("Unique thread IDs" * doctest::test_suite("threadmessaging"))
std::lock_guard<std::mutex> guard(assigned_ids_lock);
if (assigned_ids.size() == expected_ids)
{
all_done.notify_all();
break;
}
}
Expand Down