Namespaces
Variants

std:: atomic_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
atomic_notify_all
(C++20)
Free functions for atomic flags
定义于头文件 <atomic>
template < class T >
void atomic_notify_all ( std:: atomic < T > * object ) ;
(1) (C++20 起)
template < class T >
void atomic_notify_all ( volatile std:: atomic < T > * object ) ;
(2) (C++20 起)

执行原子通知操作。

解除所有在原子等待操作中阻塞的线程(即 std::atomic_wait() std::atomic_wait_explicit() std::atomic::wait() ),如果存在此类线程;否则不执行任何操作。

相当于 object - > notify_all ( )

目录

参数

object - 指向待通知原子对象的指针

返回值

(无)

注释

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

示例

参见

(C++20)
通知至少一个在原子对象上等待的线程
( std::atomic<T> 的公开成员函数)
(C++20)
通知所有在原子对象上阻塞等待的线程
( std::atomic<T> 的公开成员函数)
阻塞线程直至收到通知且原子值发生变化
(函数模板)
通知在 atomic_wait 中阻塞的线程
(函数模板)