std::atomic_wait, std::atomic_wait_explicit
Min standard notice:
Header: <atomic>
Performs atomic waiting operations. Behaves as if it repeatedly performs the following steps:
# Declarations
template< class T >
void atomic_wait( const std::atomic<T>* object,
typename std::atomic<T>::value_type old );
(since C++20)
template< class T >
void atomic_wait( const volatile std::atomic<T>* object,
typename std::atomic<T>::value_type old );
(since C++20)
template< class T >
void atomic_wait_explicit( const std::atomic<T>* object,
typename std::atomic<T>::value_type old,
std::memory_order order );
(since C++20)
template< class T >
void atomic_wait_explicit( const volatile std::atomic<T>* object,
typename std::atomic<T>::value_type old,
std::memory_order order );
(since C++20)
# Parameters
object: pointer to the atomic object to check and wait onold: the value to check the atomic object no longer containsorder: the memory synchronization ordering
# Return value
(none)
# Notes
This form of change-detection is often more efficient than simple polling or pure spinlocks.
Due to the ABA problem, transient changes from old to another value and back to old might be missed, and not unblock.
The comparison is bitwise (similar to std::memcmp); no comparison operator is used. Padding bits that never participate in an object’s value representation are ignored.
# Example
This section is incompleteReason: no example