Wakes a thread that waits with any lock it can drop and retake.
More...
#include <StormByte/safe/condition_variable_any.hxx>
|
| | ConditionVariableAny () |
| | Condition with no waiters.
|
| | ConditionVariableAny (const ConditionVariableAny &)=delete |
| | ConditionVariableAny (ConditionVariableAny &&)=delete |
| | ~ConditionVariableAny () noexcept |
| | Destroys the signal on Base's heap.
|
| ConditionVariableAny & | operator= (const ConditionVariableAny &)=delete |
| ConditionVariableAny & | operator= (ConditionVariableAny &&)=delete |
| void | notify_one () noexcept |
| | Wake one waiter.
|
| void | notify_all () noexcept |
| | Wake every waiter.
|
template<class Lock>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); } |
| void | wait (Lock &lock) |
| | Wait until notified.
|
template<class Lock, class Predicate>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); } |
| void | wait (Lock &lock, Predicate pred) |
| | Wait until pred is true.
|
template<class Lock, class Rep, class Period>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); } |
| CvStatus | wait_for (Lock &lock, const std::chrono::duration< Rep, Period > &rel) |
| | Wait until notified or rel elapses.
|
template<class Lock, class Rep, class Period, class Predicate>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); } |
| bool | wait_for (Lock &lock, const std::chrono::duration< Rep, Period > &rel, Predicate pred) |
| | Wait until pred is true or rel elapses.
|
template<class Lock, class Clock, class Duration>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); } |
| CvStatus | wait_until (Lock &lock, const std::chrono::time_point< Clock, Duration > &abs) |
| | Wait until notified or abs is reached.
|
template<class Lock, class Clock, class Duration, class Predicate>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); } |
| bool | wait_until (Lock &lock, const std::chrono::time_point< Clock, Duration > &abs, Predicate pred) |
| | Wait until pred is true or abs is reached.
|
Wakes a thread that waits with any lock it can drop and retake.
Not a ConditionVariable. That one accepts only UniqueLock. This one accepts UniqueLock, SharedLock and any other lock with lock() and unlock(). The signal lives on Base's heap. A spurious wake is valid. The predicate overloads filter it in the caller.
◆ ConditionVariableAny() [1/3]
| StormByte::Safe::ConditionVariableAny::ConditionVariableAny |
( |
| ) |
|
Condition with no waiters.
- Exceptions
-
◆ ConditionVariableAny() [2/3]
| StormByte::Safe::ConditionVariableAny::ConditionVariableAny |
( |
const ConditionVariableAny & | | ) |
|
|
delete |
◆ ConditionVariableAny() [3/3]
| StormByte::Safe::ConditionVariableAny::ConditionVariableAny |
( |
ConditionVariableAny && | | ) |
|
|
delete |
◆ ~ConditionVariableAny()
| StormByte::Safe::ConditionVariableAny::~ConditionVariableAny |
( |
| ) |
|
|
noexcept |
Destroys the signal on Base's heap.
- Note
- No thread may be waiting.
◆ notify_all()
| void StormByte::Safe::ConditionVariableAny::notify_all |
( |
| ) |
|
|
noexcept |
◆ notify_one()
| void StormByte::Safe::ConditionVariableAny::notify_one |
( |
| ) |
|
|
noexcept |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ wait() [1/2]
template<class Lock>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); }
| void StormByte::Safe::ConditionVariableAny::wait |
( |
Lock & | lock | ) |
|
|
inline |
Wait until notified.
May wake spuriously.
- Template Parameters
-
| Lock | Lock with lock() and unlock(). |
- Parameters
-
| lock | Lock held by the caller. Dropped while waiting and retaken before return. |
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait() [2/2]
template<class Lock, class Predicate>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); }
| void StormByte::Safe::ConditionVariableAny::wait |
( |
Lock & | lock, |
|
|
Predicate | pred ) |
|
inline |
Wait until pred is true.
- Template Parameters
-
| Lock | Lock with lock() and unlock(). |
| Predicate | Callable invoked with the lock held. Its result is tested as a bool. |
- Parameters
-
| lock | Lock held by the caller. |
| pred | Predicate. Evaluated in the caller. |
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_for() [1/2]
template<class Lock, class Rep, class Period>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); }
| CvStatus StormByte::Safe::ConditionVariableAny::wait_for |
( |
Lock & | lock, |
|
|
const std::chrono::duration< Rep, Period > & | rel ) |
|
inline |
Wait until notified or rel elapses.
- Template Parameters
-
| Lock | Lock with lock() and unlock(). |
| Rep | Tick representation of rel. |
| Period | Tick period of rel. |
- Parameters
-
| lock | Lock held by the caller. |
| rel | Relative timeout. |
- Returns
- Whether the wait timed out. A spurious wake is CvStatus::NoTimeout.
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_for() [2/2]
template<class Lock, class Rep, class Period, class Predicate>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); }
| bool StormByte::Safe::ConditionVariableAny::wait_for |
( |
Lock & | lock, |
|
|
const std::chrono::duration< Rep, Period > & | rel, |
|
|
Predicate | pred ) |
|
inline |
Wait until pred is true or rel elapses.
- Template Parameters
-
| Lock | Lock with lock() and unlock(). |
| Rep | Tick representation of rel. |
| Period | Tick period of rel. |
| Predicate | Callable invoked with the lock held. Its result is tested as a bool. |
- Parameters
-
| lock | Lock held by the caller. |
| rel | Relative timeout. |
| pred | Predicate. Evaluated in the caller. |
- Returns
- Whether
pred is true on return.
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_until() [1/2]
template<class Lock, class
Clock, class Duration>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); }
| CvStatus StormByte::Safe::ConditionVariableAny::wait_until |
( |
Lock & | lock, |
|
|
const std::chrono::time_point< Clock, Duration > & | abs ) |
|
inline |
Wait until notified or abs is reached.
- Template Parameters
-
| Lock | Lock with lock() and unlock(). |
| Clock | Clock of abs. |
| Duration | Duration of abs. |
- Parameters
-
| lock | Lock held by the caller. |
| abs | Absolute time. |
- Returns
- Whether the wait timed out.
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_until() [2/2]
template<class Lock, class
Clock, class Duration, class Predicate>
requires requires(Lock& lock) { lock.lock(); lock.unlock(); }
| bool StormByte::Safe::ConditionVariableAny::wait_until |
( |
Lock & | lock, |
|
|
const std::chrono::time_point< Clock, Duration > & | abs, |
|
|
Predicate | pred ) |
|
inline |
Wait until pred is true or abs is reached.
- Template Parameters
-
| Lock | Lock with lock() and unlock(). |
| Clock | Clock of abs. |
| Duration | Duration of abs. |
| Predicate | Callable invoked with the lock held. Its result is tested as a bool. |
- Parameters
-
| lock | Lock held by the caller. |
| abs | Absolute time. |
| pred | Predicate. Evaluated in the caller. |
- Returns
- Whether
pred is true on return.
- Precondition
lock owns its mutex.
- Exceptions
-
The documentation for this class was generated from the following file: