Skip to content

Commit

Permalink
Fix ds_test hang - remove unsafe condition_variable (microsoft#5119)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyashton authored Mar 17, 2023
1 parent e55469b commit 82ea63a
Showing 1 changed file with 0 additions and 9 deletions.
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

0 comments on commit 82ea63a

Please sign in to comment.