Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::latch Class Reference

#include <latch.hpp>

Public Member Functions

 latch (std::size_t count)
 Constructs a latch with a given count. More...
 
 ~latch ()
 Destructor Precondition: No threads are waiting or invoking count_down on *this. More...
 
void wait ()
 Blocks until the latch has counted down to zero. More...
 
bool try_wait ()
 
template<class Rep , class Period >
cv_status wait_for (const chrono::duration< Rep, Period > &rel_time)
 try to wait for a specified amount of time is elapsed. More...
 
template<class Clock , class Duration >
cv_status wait_until (const chrono::time_point< Clock, Duration > &abs_time)
 try to wait until the specified time_point is reached More...
 
void count_down ()
 Decrement the count and notify anyone waiting if we reach zero. More...
 
bool try_count_down ()
 Effect: Decrement the count if it is > 0 and notify anyone waiting if we reached zero. More...
 
void signal ()
 
void count_down_and_wait ()
 Decrement the count and notify anyone waiting if we reach zero. More...
 
void sync ()
 
void reset (std::size_t count)
 Reset the counter #Requires This method may only be invoked when there are no other threads currently inside the count_down_and_wait() method. More...
 

Constructor & Destructor Documentation

boost::latch::latch ( std::size_t  count)
inline

Constructs a latch with a given count.

boost::latch::~latch ( )
inline

Destructor Precondition: No threads are waiting or invoking count_down on *this.

Member Function Documentation

void boost::latch::count_down ( )
inline

Decrement the count and notify anyone waiting if we reach zero.

count must be greater than 0

Referenced by count_down_and_wait(), and signal().

void boost::latch::count_down_and_wait ( )
inline

Decrement the count and notify anyone waiting if we reach zero.

Blocks until the latch has counted down to zero. count must be greater than 0

References count_down(), and boost::condition_variable::wait().

Referenced by sync().

void boost::latch::reset ( std::size_t  count)
inline

Reset the counter #Requires This method may only be invoked when there are no other threads currently inside the count_down_and_wait() method.

References count.

void boost::latch::signal ( )
inline

References count_down().

void boost::latch::sync ( )
inline

References count_down_and_wait().

bool boost::latch::try_count_down ( )
inline

Effect: Decrement the count if it is > 0 and notify anyone waiting if we reached zero.

Returns: true if count_ was 0 or reached 0.

bool boost::latch::try_wait ( void  )
inline
Returns
true if the internal counter is already 0, false otherwise
void boost::latch::wait ( void  )
inline

Blocks until the latch has counted down to zero.

References boost::condition_variable::wait().

template<class Rep , class Period >
cv_status boost::latch::wait_for ( const chrono::duration< Rep, Period > &  rel_time)
inline

try to wait for a specified amount of time is elapsed.

Returns
whether there is a timeout or not.
template<class Clock , class Duration >
cv_status boost::latch::wait_until ( const chrono::time_point< Clock, Duration > &  abs_time)
inline

try to wait until the specified time_point is reached

Returns
whether there were a timeout or not.

The documentation for this class was generated from the following file: