constructor( size_t );
The parameter is the initial value of the internal counter.
destructor( );
Destroys the latch.However, if the latch is destroyed while other threads are in wait(), or are invoking count_down(), the behaviour is undefined.
void count_down( );
Decrements the internal count by 1, and returns. If the count reaches 0, any threads blocked in wait() will be released.
Throws std::logic_error if the internal count is already 0.
void wait( );
Blocks the calling thread until the internal count is decremented to 0 by one or more other threads calling count_down(). If the count is already 0, this is a no-op.
bool try_wait( );
Returns true if the internal count has been decremented to 0 by one or more other threads calling count_down(), and false otherwise. Does not block the calling thread.
void count_down_and_wait( );
Decrements the internal count by 1. If the resulting count is not 0, blocks the calling thread until the internal count is decremented to 0 by one or more other threads calling count_down().
Can read more from the proposal n4204.
________________________________________________
Comments