tmc::latch#
An async version of std::latch.
API Reference#
-
class latch#
Similar semantics to std::latch, exposing all operations except
arrive_and_wait()
.Public Functions
-
inline latch(size_t Count) noexcept#
Sets the initial value of Count. After
count_down()
has been called Count times, all future waiters will resume. Setting this to zero or a negative number will cause awaiters to resume immediately.
-
inline bool is_ready() noexcept#
Returns true after
count_down()
has been calledCount
times. After this returns true, all subsequent calls toco_await
will resume immediately. Equivalent tostd::latch::try_wait()
.
-
inline bool count_down() noexcept#
Decrements the counter and returns the value of
is_ready()
after the counter is decremented. If this becomes ready after this call tocount_down()
, all awaiters will be resumed immediately. Equivalent tostd::latch::count_down()
.
-
inline tmc::aw_manual_reset_event operator co_await() noexcept#
Waits until the counter becomes zero. Does not decrement the counter - you must call
count_down()
separately. Equivalent tostd::latch::wait()
.
-
~latch() = default#
On destruction, any awaiters will be resumed.
-
inline latch(size_t Count) noexcept#