|
Mutexed 0.0.1
A header-only mutex-protected value wrapper for C++20.
|
The waiting feature is enabled if H is has_cv. More...
Functions | |
| template<typename Predicate > requires std::is_same_v<H, has_cv> && invokable_with<Predicate, T const&> | |
| void | llh::mutexed::Mutexed< T, M, H >::wait (Predicate &&p) const |
Waits until this is notified and the provided predicate returns true. | |
| template<class Rep , class Period , typename Predicate > requires std::is_same_v<H, has_cv> && invokable_with<Predicate, T const&> | |
| bool | llh::mutexed::Mutexed< T, M, H >::wait_for (std::chrono::duration< Rep, Period > const &rel_time, Predicate &&p) const |
Waits until this is notified and the provided predicate returns true or until the specified duration has been spent waiting. | |
| template<class Clock , class Duration , typename Predicate > requires std::is_same_v<H, has_cv> && invokable_with<Predicate, T const&> | |
| bool | llh::mutexed::Mutexed< T, M, H >::wait_until (std::chrono::time_point< Clock, Duration > const &timeout_time, Predicate &&p) const |
Waits until this is notified and the provided predicate returns true or until the specified time point has been passed. | |
The waiting feature is enabled if H is has_cv.
It makes available the three waiting functions that mirror the three waiting methods of std::condition_variable and use them internally with a possibly_shared_lock as first argument.
Internally, the Mutexed will hold a condition-variable that will be notified with notify_all() after the unlocking that occurs whenever the inner value has been write-accessed, which happens at the end of the calls to the non-const versions of locked() and with_locked().
Here is an example of waiting on a Mutexed :
|
inline |
Waits until this is notified and the provided predicate returns true.
Calling this function is blocking.
The predicate is called with the inner value shared-locked if it is shared_lockable , and unique-locked otherwise.
Definition at line 365 of file mutexed.hpp.
|
inline |
Waits until this is notified and the provided predicate returns true or until the specified duration has been spent waiting.
Calling this function is blocking.
The predicate is called with the inner value shared-locked if it is shared_lockable , and unique-locked otherwise.
Definition at line 377 of file mutexed.hpp.
|
inline |
Waits until this is notified and the provided predicate returns true or until the specified time point has been passed.
Calling this function is blocking.
The predicate is called with the inner value shared-locked if it is shared_lockable , and unique-locked otherwise.
Definition at line 389 of file mutexed.hpp.