|
Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
|
Inspired by std::latch of C++20. More...
#include <latch.hpp>
Public Member Functions | |
| latch () noexcept=default | |
| Initialize instance with counter zero. | |
| latch (const latch &o)=delete | |
| No copy constructor nor move constructor. | |
| latch (const size_t count_) noexcept | |
| Initialize instance with given counter. | |
| void | arrive_and_wait (const size_t n=1) noexcept |
| Atomically decrements the internal counter by n and (if necessary) blocks the calling thread until the counter reaches zero. | |
| bool | arrive_and_wait_for (const fraction_i64 &timeout_duration, const size_t n=1) noexcept |
| Atomically decrements the internal counter by n and (if necessary) blocks the calling thread until the counter reaches zero or the given timeout duration has expired. | |
| template<typename Rep, typename Period> | |
| bool | arrive_and_wait_for (const std::chrono::duration< Rep, Period > &timeout_duration, const size_t n=1) noexcept |
| Atomically decrements the internal counter by n and (if necessary) blocks the calling thread until the counter reaches zero or the given timeout duration has expired. | |
| void | count_down (const size_t n=1) noexcept |
| Atomically decrements the internal counter by n and notifies all blocked wait() threads if zero is reached. | |
| void | count_up (const size_t n=1) noexcept |
| Atomically increments the internal counter by n, i.e. | |
| void | set (const size_t n) noexcept |
| Atomically set the internal counter by n. | |
| bool | try_wait () const noexcept |
| Returns true only if the internal counter has reached zero. | |
| size_t | value () const noexcept |
| Return the current atomic internal counter. | |
| void | wait () const noexcept |
| Blocks the calling thread until the internal counter reaches 0. | |
| bool | wait_for (const fraction_i64 &timeout_duration) const noexcept |
| Blocks the calling thread until the internal counter reaches 0 or the given timeout duration has expired. | |
| template<typename Rep, typename Period> | |
| bool | wait_for (const std::chrono::duration< Rep, Period > &timeout_duration) const noexcept |
| Blocks the calling thread until the internal counter reaches 0 or the given timeout duration has expired. | |
Static Public Member Functions | |
| static constexpr size_t | max () noexcept |
| Returns the maximum value of the internal counter supported by the implementation. | |
Inspired by std::latch of C++20.
Adds count_up() as an extension, allowing to dynamically add events to required to complete.
|
defaultnoexcept |
Initialize instance with counter zero.
Useful for member instances in combination with count_up() or with set() before count_down().
Extension of std::latch.
|
inlinenoexcept |
|
delete |
No copy constructor nor move constructor.
Compatible with std::latch.
| o |
|
inlinestaticconstexprnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Atomically decrements the internal counter by n and notifies all blocked wait() threads if zero is reached.
If n is greater than the value of the internal counter, the counter is set to zero.
This operation strongly happens-before all calls that are unblocked on this latch.
Compatible with std::latch.
| n | the value by which the internal counter is decreased, defaults to 1 |
Definition at line 107 of file latch.hpp.
|
inlinenoexcept |
Atomically increments the internal counter by n, i.e.
adds value to count down.
If internal counter + n is greater than the maximum value of the internal counter, the counter is set to its maximum.
This operation strongly happens-before all calls that are unblocked on this latch.
Extension of std::latch.
| n | the value by which the internal counter is increased, defaults to 1 |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Atomically decrements the internal counter by n and (if necessary) blocks the calling thread until the counter reaches zero.
Equivalent to count_down(n); wait();.
Compatible with std::latch.
| n | the value by which the internal counter is decreased, defaults to 1 |
Definition at line 192 of file latch.hpp.
|
inlinenoexcept |
Blocks the calling thread until the internal counter reaches 0 or the given timeout duration has expired.
If the internal counter is zero already, returns immediately.
Implementation uses wait_for() w/ a monotonic clock and fraction_i64.
Extension of std::latch.
| timeout_duration | maximum duration in fractions of seconds to wait |
Definition at line 209 of file latch.hpp.
|
inlinenoexcept |
Atomically decrements the internal counter by n and (if necessary) blocks the calling thread until the counter reaches zero or the given timeout duration has expired.
Equivalent to count_down(n); wait(timeout_duration);.
Implementation uses std::chrono::steady_clock::now() and fraction_i64.
Extension of std::latch.
| timeout_duration | maximum duration in fractions of seconds to wait |
| n | the value by which the internal counter is decreased, defaults to 1 |
Definition at line 240 of file latch.hpp.
|
inlinenoexcept |
Blocks the calling thread until the internal counter reaches 0 or the given timeout duration has expired.
If the internal counter is zero already, returns immediately.
Implementation uses std::chrono::steady_clock::now().
Extension of std::latch.
| Rep | |
| Period |
| timeout_duration | maximum duration to wait |
|
inlinenoexcept |
Atomically decrements the internal counter by n and (if necessary) blocks the calling thread until the counter reaches zero or the given timeout duration has expired.
Equivalent to count_down(n); wait(timeout_duration);.
Implementation uses std::chrono::steady_clock::now().
Extension of std::latch.
| Rep | |
| Period |
| timeout_duration | maximum duration to wait |
| n | the value by which the internal counter is decreased, defaults to 1 |