Namespaces
Variants

std::atomic_ref<T>:: 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 ( ) const noexcept ;
(自 C++26 起为 constexpr)

执行原子通知操作。

解除所有在 * ptr 上因原子等待操作(即 wait() )而阻塞的线程(如果存在);否则不执行任何操作。 此重载仅当 std:: is_const_v < T > false 时参与重载决议。

目录

注释

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

示例

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。

缺陷报告 应用于 发布时的行为 正确行为
LWG 3508
( P3323R1 )
C++20 notify_all 对于 const T 无意义 约束为仅接受非 const T

参见

阻塞线程直至被通知且原子值发生变化
(公开成员函数)
阻塞线程直至被通知且原子值发生变化
(函数模板)
通知阻塞在 atomic_wait 的线程
(函数模板)