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 called Count times. After this returns true, all subsequent calls to co_await will resume immediately. Equivalent to std::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 to count_down(), all awaiters will be resumed immediately. Equivalent to std::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 to std::latch::wait().

~latch() = default#

On destruction, any awaiters will be resumed.