0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Attributes | List of all members
Hypertable::Barrier Class Reference

A Barrier to block execution of code. More...

#include <Barrier.h>

Classes

class  ScopedActivator
 A helper class to put up a barrier when entering a scope and take it down when leaving the scope. More...
 

Public Member Functions

 Barrier ()
 
void enter ()
 Enters the critical section. More...
 
void exit ()
 Leaves the critical section; will wake up/notify waiting threads if necessary. More...
 
void put_up ()
 "Puts" the barrier "up". More...
 
void take_down ()
 "Takes" the barrier "down"; all threads waiting in enter() are allowed to continue. More...
 

Private Attributes

std::mutex m_mutex
 Mutex to lock access to the members and conditions. More...
 
std::condition_variable m_unblocked_cond
 Condition to wait for when barrier is up. More...
 
std::condition_variable m_quiesced_cond
 Condition to wait for to take the barrier down. More...
 
bool m_hold
 True if the barrier is up. More...
 
uint32_t m_counter {}
 Number of threads that have enter()ed (but not exit()ed) the code. More...
 

Detailed Description

A Barrier to block execution of code.

Definition at line 44 of file Barrier.h.

Constructor & Destructor Documentation

Hypertable::Barrier::Barrier ( )
inline

Definition at line 46 of file Barrier.h.

Member Function Documentation

void Hypertable::Barrier::enter ( )
inline

Enters the critical section.

If the barrier is "up" then this thread will wait till the barrier is "down" again, then it can continue execution.

Definition at line 52 of file Barrier.h.

void Hypertable::Barrier::exit ( )
inline

Leaves the critical section; will wake up/notify waiting threads if necessary.

Definition at line 61 of file Barrier.h.

void Hypertable::Barrier::put_up ( )
inline

"Puts" the barrier "up".

If any threads are currently executing the blocked code then this thread will wait till they are done. Otherwise only the current thread can execute the code.

Definition at line 73 of file Barrier.h.

void Hypertable::Barrier::take_down ( )
inline

"Takes" the barrier "down"; all threads waiting in enter() are allowed to continue.

Definition at line 83 of file Barrier.h.

Member Data Documentation

uint32_t Hypertable::Barrier::m_counter {}
private

Number of threads that have enter()ed (but not exit()ed) the code.

Definition at line 127 of file Barrier.h.

bool Hypertable::Barrier::m_hold
private

True if the barrier is up.

Definition at line 124 of file Barrier.h.

std::mutex Hypertable::Barrier::m_mutex
private

Mutex to lock access to the members and conditions.

Definition at line 115 of file Barrier.h.

std::condition_variable Hypertable::Barrier::m_quiesced_cond
private

Condition to wait for to take the barrier down.

Definition at line 121 of file Barrier.h.

std::condition_variable Hypertable::Barrier::m_unblocked_cond
private

Condition to wait for when barrier is up.

Definition at line 118 of file Barrier.h.


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