Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/atomic/atomic notify all"

From cppreference.com
< cpp‎ | atomic
m
(Splitted the volatile overloads.)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 
{{cpp/title|atomic_notify_all}}
 
{{cpp/title|atomic_notify_all}}
{{cpp/atomic/navbar}}
+
{{cpp/thread/navbar}}
 
{{dcl begin}}
 
{{dcl begin}}
{{dcl header | atomic }}
+
{{dcl header|atomic}}
{{dcl rev begin | since=c++20}}
+
{{dcl|num=1|since=c++20|
{{dcl |  
+
 
template< class T >
 
template< class T >
 
void atomic_notify_all( std::atomic<T>* object );
 
void atomic_notify_all( std::atomic<T>* object );
 
}}
 
}}
{{dcl |
+
{{dcl|num=2|since=c++20|
 
template< class T >
 
template< class T >
 
void atomic_notify_all( volatile std::atomic<T>* object );
 
void atomic_notify_all( volatile std::atomic<T>* object );
 
}}
 
}}
{{dcl rev end}}
 
 
{{dcl end}}
 
{{dcl end}}
  
 
Performs atomic notifying operations.
 
Performs atomic notifying operations.
  
Unblocks all threads blocked in atomic waiting operations (i.e. {{lc|std::atomic_wait()}}, {{lc|std::atomic_wait_explicit()}}, or {{lc|std::atomic::wait()}}) on {{c|*object}}, if there are any; otherwise does nothing.
+
Unblocks all threads blocked in atomic waiting operations (i.e. {{lc|std::atomic_wait()}}, {{lc|std::atomic_wait_explicit()}}, or {{l2tf std|cpp/atomic/atomic/wait}}) on {{c|*object}}, if there are any; otherwise does nothing.
  
 
Equivalent to {{c|object->notify_all()}}.
 
Equivalent to {{c|object->notify_all()}}.
Line 23: Line 21:
 
===Parameters===
 
===Parameters===
 
{{par begin}}
 
{{par begin}}
{{par | object | pointer to the atomic object to notify}}
+
{{par|object|pointer to the atomic object to notify}}
 
{{par end}}  
 
{{par end}}  
  
Line 37: Line 35:
 
===See also===
 
===See also===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc inc | cpp/atomic/atomic/dsc notify_one | atomic}}
+
{{dsc inc|cpp/atomic/atomic/dsc notify_one|atomic}}
{{dsc inc | cpp/atomic/atomic/dsc notify_all | atomic}}
+
{{dsc inc|cpp/atomic/atomic/dsc notify_all|atomic}}
{{dsc inc | cpp/atomic/dsc atomic_wait}}
+
{{dsc inc|cpp/atomic/dsc atomic_wait}}
{{dsc inc | cpp/atomic/dsc atomic_notify_one}}
+
{{dsc inc|cpp/atomic/dsc atomic_notify_one}}
 
{{dsc end}}
 
{{dsc end}}
  
 
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
 
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}

Latest revision as of 19:02, 24 September 2023

 
 
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
Safe Reclamation
(C++26)
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
Free functions for atomic operations
atomic_notify_all
(C++20)
Free functions for atomic flags
 
Defined in header <atomic>
template< class T >
void atomic_notify_all( std::atomic<T>* object );
(1) (since C++20)
template< class T >
void atomic_notify_all( volatile std::atomic<T>* object );
(2) (since C++20)

Performs atomic notifying operations.

Unblocks all threads blocked in atomic waiting operations (i.e. std::atomic_wait(), std::atomic_wait_explicit(), or std::atomic::wait()) on *object, if there are any; otherwise does nothing.

Equivalent to object->notify_all().

Contents

[edit] Parameters

object - pointer to the atomic object to notify

[edit] Return value

(none)

[edit] Notes

This form of change-detection is often more efficient than simple polling or pure spinlocks.

[edit] Example

[edit] See also

notifies at least one thread waiting on the atomic object
(public member function of std::atomic<T>) [edit]
notifies all threads blocked waiting on the atomic object
(public member function of std::atomic<T>) [edit]
blocks the thread until notified and the atomic value changes
(function template) [edit]
notifies a thread blocked in atomic_wait
(function template) [edit]