This class represents a coroutine-compatible implementation of the std::condition_variable. Most methods of the latter have been recreated with the same behavior. This object will yield instead of blocking if called from a coroutine.
More...
|
| ConditionVariable () |
| Default constructor. More...
|
|
| ConditionVariable (const ConditionVariable &other)=delete |
|
| ConditionVariable (ConditionVariable &&other)=delete |
|
ConditionVariable & | operator= (const ConditionVariable &other)=delete |
|
ConditionVariable & | operator= (ConditionVariable &&other)=delete |
|
| ~ConditionVariable () |
| Destructor. More...
|
|
void | notifyOne () |
| Notify one waiting thread or coroutine. More...
|
|
void | notifyAll () |
| Notify all waiting threads and coroutines. More...
|
|
void | wait (Mutex &mutex) |
| Block the current thread until the condition is signalled via notifyOne() or notifyAll(). More...
|
|
void | wait (ICoroSync::Ptr sync, Mutex &mutex) |
| Yield the current coroutine until the condition is signalled via notifyOne() or notifyAll(). More...
|
|
template<class PREDICATE = bool()> |
void | wait (Mutex &mutex, PREDICATE predicate) |
| Block the current thread until the condition is signalled via notifyOne() or notifyAll(). More...
|
|
template<class PREDICATE = bool()> |
void | wait (ICoroSync::Ptr sync, Mutex &mutex, PREDICATE predicate) |
| Yield the current coroutine until the condition is signalled via notifyOne() or notifyAll(). When this function returns, the mutex is guaranteed to be locked. More...
|
|
template<class REP , class PERIOD > |
bool | waitFor (Mutex &mutex, const std::chrono::duration< REP, PERIOD > &time) |
| Block the current thread until the condition is signalled via notifyOne() or notifyAll() or until 'time' duration expires. More...
|
|
template<class REP , class PERIOD > |
bool | waitFor (ICoroSync::Ptr sync, Mutex &mutex, const std::chrono::duration< REP, PERIOD > &time) |
| Block the current thread until the condition is signalled via notifyOne() or notifyAll() or until 'time' duration expires. More...
|
|
template<class REP , class PERIOD , class PREDICATE = bool()> |
bool | waitFor (Mutex &mutex, const std::chrono::duration< REP, PERIOD > &time, PREDICATE predicate) |
| Block the current thread until the condition is signalled via notifyOne() or notifyAll() or until 'time' duration expires. More...
|
|
template<class REP , class PERIOD , class PREDICATE = bool()> |
bool | waitFor (ICoroSync::Ptr sync, Mutex &mutex, const std::chrono::duration< REP, PERIOD > &time, PREDICATE predicate) |
| Block the current thread until the condition is signalled via notifyOne() or notifyAll() or until 'time' duration expires. More...
|
|
This class represents a coroutine-compatible implementation of the std::condition_variable. Most methods of the latter have been recreated with the same behavior. This object will yield instead of blocking if called from a coroutine.
template<class PREDICATE >
void Bloomberg::quantum::ConditionVariable::wait |
( |
ICoroSync::Ptr |
sync, |
|
|
Mutex & |
mutex, |
|
|
PREDICATE |
predicate |
|
) |
| |
Yield the current coroutine until the condition is signalled via notifyOne() or notifyAll(). When this function returns, the mutex is guaranteed to be locked.
When this function returns, the mutex is guaranteed to be locked. This function calls wait() in a loop until the predicate returns true. This ensures that the condition has not changed after notifyOne() or notifyAll() have been called. The internal logic is equivalent to:
- Template Parameters
-
PREDICATE | Callable function type having the following signature 'bool f()'. |
- Parameters
-
[in] | sync | Pointer to a coroutine synchronization object. |
[in] | mutex | Mutex object which is locked by the current coroutine. |
[in] | predicate | Function or functor to be tested as exit condition of the endless while loop. |
- Note
- This function should be called from a coroutine.
template<class REP , class PERIOD , class PREDICATE >
bool Bloomberg::quantum::ConditionVariable::waitFor |
( |
Mutex & |
mutex, |
|
|
const std::chrono::duration< REP, PERIOD > & |
time, |
|
|
PREDICATE |
predicate |
|
) |
| |
Block the current thread until the condition is signalled via notifyOne() or notifyAll() or until 'time' duration expires.
When this function returns, the mutex is guaranteed to be locked. This function calls wait() in a loop until the predicate returns true or 'time' expires. This ensures that the condition has not changed after notifyOne() or notifyAll() have been called. The internal logic is equivalent to:
- Template Parameters
-
REP | An arithmetic type such as int or double representing the number of ticks. |
PERIOD | A std::ratio representing the tick period such as ticks per second. |
PREDICATE | Callable function type having the following signature 'bool f()'. |
- Parameters
-
[in] | mutex | Mutex object which is locked by the current coroutine. |
[in] | time | Maximum duration for which to wait on this condition. |
[in] | predicate | Function or functor to be tested as exit condition of the endless while loop. |
- Returns
- True if the mutex was acquired before 'time' expired, otherwise the predicate result after timeout.
- Note
- This function should be called from a regular thread not from a coroutine.
template<class REP , class PERIOD , class PREDICATE >
bool Bloomberg::quantum::ConditionVariable::waitFor |
( |
ICoroSync::Ptr |
sync, |
|
|
Mutex & |
mutex, |
|
|
const std::chrono::duration< REP, PERIOD > & |
time, |
|
|
PREDICATE |
predicate |
|
) |
| |
Block the current thread until the condition is signalled via notifyOne() or notifyAll() or until 'time' duration expires.
When this function returns, the mutex is guaranteed to be locked. This function calls wait() in a loop until the predicate returns true or 'time' expires. This ensures that the condition has not changed after notifyOne() or notifyAll() have been called. The internal logic is equivalent to:
- Template Parameters
-
REP | An arithmetic type such as int or double representing the number of ticks. |
PERIOD | A std::ratio representing the tick period such as ticks per second. |
PREDICATE | Callable function type having the following signature 'bool f()'. |
- Parameters
-
[in] | sync | Pointer to a coroutine synchronization object. |
[in] | mutex | Mutex object which is locked by the current coroutine. |
[in] | time | Maximum duration for which to wait on this condition. |
[in] | predicate | Function or functor to be tested as exit condition of the endless while loop. |
- Returns
- True if the mutex was acquired before 'time' expired, otherwise the predicate result after timeout.
- Note
- This function should be called from a coroutine.