From cppreference.com
The condition_variable_any class is a generalization of
. Whereas
works only on std::unique_lock<std::mutex>, condition_variable_any can operate on any lock that meets the
requirements.
See
for the description of the semantics of condition variables.
The class std::condition_variable_any is a
. It is not
,
,
, or
.
If the lock is std::unique_lock<std::mutex>,
may provide better performance.
Member functions
constructs the object
(public member function)
destructs the object
(public member function)
operator=
[deleted]
not copy-assignable
(public member function)
Notification
notifies one waiting thread
(public member function)
notifies all waiting threads
(public member function)
Waiting
blocks the current thread until the condition variable is awakened
(public member function)
blocks the current thread until the condition variable is awakened or after the specified timeout duration
(public member function)
blocks the current thread until the condition variable is awakened or until specified time point has been reached
(public member function)
Notes
std::condition_variable_any can be used with
in order to wait on a
in shared ownership mode.
A possible use for std::condition_variable_any with custom
types is to provide convenient interruptible waits: the custom lock operation would both lock the associated mutex as expected, and also perform the necessary setup to notify this condition variable when the interrupting signal is received.
See also
External links
Anthony Williams (2012, 1st ed./ 2019, 2nd ed.), “C++ Concurrency in Action”, 9.2.4 “Interrupting a wait on std::condition_variable_any”.