[thread.condition.general] (original) (raw)
32 Concurrency support library [thread]
32.7 Condition variables [thread.condition]
32.7.1 General [thread.condition.general]
Condition variables provide synchronization primitives used to block a thread until notified by some other thread that some condition is met or until a system time is reached.
Class condition_variable provides a condition variable that can only wait on an object of type unique_lock<mutex>, allowing the implementation to be more efficient.
Class condition_variable_any provides a general condition variable that can wait on objects of user-supplied lock types.
Condition variables permit concurrent invocation of the wait, wait_for,wait_until, notify_one and notify_all member functions.
The executions of notify_one and notify_allare atomic.
The executions of wait, wait_for, and wait_until are performed in three atomic parts:
1. | the release of the mutex and entry into the waiting state; |
---|---|
2. | the unblocking of the wait; and |
3. | the reacquisition of the lock. |
The implementation behaves as if all executions of notify_one, notify_all, and each part of the wait, wait_for, and wait_until executions are executed in a single unspecified total order consistent with the “happens before” order.
Condition variable construction and destruction need not be synchronized.