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 @@ -56,15 +56,21 @@ struct TestFn {
56
56
{
57
57
volatile A a (T (2 ));
58
58
static_assert (noexcept (std::atomic_notify_all (&a)), " " );
59
- auto f = [&]() {
59
+
60
+ std::atomic<bool > is_ready[2 ] = {false , false };
61
+ auto f = [&](int index) {
60
62
assert (std::atomic_load (&a) == T (2 ));
63
+ is_ready[index].store (true );
64
+
61
65
std::atomic_wait (&a, T (2 ));
62
66
assert (std::atomic_load (&a) == T (4 ));
63
67
};
64
- std::thread t1 = support::make_test_thread (f);
65
- std::thread t2 = support::make_test_thread (f);
66
- std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
68
+ std::thread t1 = support::make_test_thread (f, /* index=*/ 0 );
69
+ std::thread t2 = support::make_test_thread (f, /* index=*/ 1 );
67
70
71
+ while (!is_ready[0 ] || !is_ready[1 ]) {
72
+ // Spin
73
+ }
68
74
std::atomic_store (&a, T (4 ));
69
75
std::atomic_notify_all (&a);
70
76
t1.join ();
You can’t perform that action at this time.
0 commit comments