Namespaces
Variants

std::atomic_flag:: notify_all

From cppreference.net

Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
void notify_all ( ) noexcept ;
(1) (自 C++20 起)
(自 C++26 起为 constexpr)
void notify_all ( ) volatile noexcept ;
(2) (自 C++20 起)

执行原子通知操作。

解除所有在 * this 上因原子等待操作(即 wait() )而阻塞的线程,如果存在此类线程;否则不执行任何操作。

注释

这种变更检测形式通常比简单轮询或纯自旋锁更高效。

示例

参见

(C++20)
阻塞线程直至被通知且原子值发生变化
(公开成员函数)
阻塞线程直至被通知且标志位发生变化
(函数)
通知在 atomic_flag_wait 中阻塞的线程
(函数)