- atomic[meta header]
- std[meta namespace]
- atomic_flag[meta class]
- function[meta id-type]
- cpp20[meta cpp]
void notify_all() volatile noexcept; // (1) C++20
void notify_all() noexcept; // (2) C++20
constexpr void notify_all() noexcept; // (2) C++26
待機している全てのスレッドを起床させる。
この関数は、wait()
関数によるブロッキング待機を解除する。
起床待機している全てのアトミックオブジェクトの待機を解除する
なし
投げない
#include <iostream>
#include <atomic>
#include <thread>
int main()
{
std::atomic_flag x = ATOMIC_FLAG_INIT;
auto f = [&x] {
while (true) {
x.wait(false);
if (x.test()) {
break;
}
}
};
std::thread t1 {f};
std::thread t2 {f};
x.clear();
x.notify_all();
t1.join();
t2.join();
}
- notify_all()[color ff0000]
- test[link test.md]
- clear[link clear.md]
- wait[link wait.md]
- ATOMIC_FLAG_INIT[link /reference/atomic/atomic_flag_init.md]
- C++20
- Clang: 9.0 [mark noimpl]
- GCC: 9.2 [mark noimpl]
- Visual C++: 2019 Update 3 [mark noimpl]