Namespaces
Variants

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

执行原子通知操作。

如果在原子等待操作中有线程被阻塞(即 std::atomic_wait() std::atomic_wait_explicit() std::atomic::wait() )于 * object 上,则解除 至少一个 此类线程的阻塞;否则不执行任何操作。

相当于 object - > notify_one ( )

目录

参数

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

返回值

(无)

注释

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

示例

参见

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