Skip to content

Commit ab8e7f2

Browse files
committed
fix in sample code
待機側はatomic_flag_wait(&x,false)で値がtrueになるまで待機するが、main側はフラグをクリア(falseのまま)してからnotify するため、wait は再ブロックしデッドロックする
1 parent 685b87a commit ab8e7f2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

reference/atomic/atomic_flag_notify_all.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int main()
5959
std::thread t1 {f};
6060
std::thread t2 {f};
6161
62-
std::atomic_flag_clear(&x);
62+
std::atomic_flag_test_and_set(&x);
6363
std::atomic_flag_notify_all(&x);
6464
6565
t1.join();

0 commit comments

Comments
 (0)