File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -39,15 +39,21 @@ struct TestFn {
3939 {
4040 A a (T (1 ));
4141 static_assert (noexcept (std::atomic_notify_all (&a)), " " );
42- auto f = [&]() {
42+
43+ std::atomic<bool > is_ready[2 ] = {false , false };
44+ auto f = [&](int index) {
4345 assert (std::atomic_load (&a) == T (1 ));
46+ is_ready[index].store (true );
47+
4448 std::atomic_wait (&a, T (1 ));
4549 assert (std::atomic_load (&a) == T (3 ));
4650 };
47- std::thread t1 = support::make_test_thread (f);
48- std::thread t2 = support::make_test_thread (f);
49- std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
51+ std::thread t1 = support::make_test_thread (f, /* index=*/ 0 );
52+ std::thread t2 = support::make_test_thread (f, /* index=*/ 1 );
5053
54+ while (!is_ready[0 ] || !is_ready[1 ]) {
55+ // Spin
56+ }
5157 std::atomic_store (&a, T (3 ));
5258 std::atomic_notify_all (&a);
5359 t1.join ();
You can’t perform that action at this time.
0 commit comments