Namespaces
Variants

std::atomic_ref<T>:: notify_one

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

执行原子通知操作。

如果在原子等待操作(即 wait() )中有线程被阻塞于 * ptr ,则解除 至少一个 此类线程的阻塞;否则不执行任何操作。 此重载仅当 std:: is_const_v < T > false 时参与重载决议。

目录

注释

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

示例

缺陷报告

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

缺陷报告 适用范围 发布时行为 正确行为
LWG 3508
( P3323R1 )
C++20 notify_one const T 无意义 约束为仅接受非 const T

参见

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