29 #ifndef Common_Barrier_h
30 #define Common_Barrier_h
32 #include <condition_variable>
53 std::unique_lock<std::mutex> lock(
m_mutex);
62 std::lock_guard<std::mutex> lock(
m_mutex);
74 std::unique_lock<std::mutex> lock(
m_mutex);
84 std::lock_guard<std::mutex> lock(
m_mutex);
134 #endif // Common_Barrier_h
bool m_hold
True if the barrier is up.
Barrier & m_barrier
A reference to the Barrier.
A Barrier to block execution of code.
void exit()
Leaves the critical section; will wake up/notify waiting threads if necessary.
std::condition_variable m_unblocked_cond
Condition to wait for when barrier is up.
uint32_t m_counter
Number of threads that have enter()ed (but not exit()ed) the code.
~ScopedActivator()
Destructor; "takes down" the barrier.
std::condition_variable m_quiesced_cond
Condition to wait for to take the barrier down.
void enter()
Enters the critical section.
ScopedActivator(Barrier &barrier)
Constructor; "puts up" the barrier.
std::mutex m_mutex
Mutex to lock access to the members and conditions.
void put_up()
"Puts" the barrier "up".
void take_down()
"Takes" the barrier "down"; all threads waiting in enter() are allowed to continue.
A helper class to put up a barrier when entering a scope and take it down when leaving the scope...