Thrill
0.1
|
Implements a thread barrier using mutex locking and condition variables that can be used to synchronize threads.
Definition at line 25 of file thread_barrier_mutex.hpp.
#include <thread_barrier_mutex.hpp>
Public Member Functions | |
ThreadBarrierMutex (size_t thread_count) | |
Creates a new barrier that waits for n threads. More... | |
size_t | step () const |
return generation step bit: 0 or 1 More... | |
template<typename Lambda = NoOperation<void>> | |
void | wait (Lambda lambda=Lambda()) |
Waits for n threads to arrive. More... | |
template<typename Lambda = NoOperation<void>> | |
void | wait_yield (Lambda lambda=Lambda()) |
Waits for n threads to arrive. More... | |
Protected Attributes | |
size_t | counts_ [2] = { 0, 0 } |
two counters: switch between them every run. More... | |
std::condition_variable | cv_ |
condition variable everyone waits on for the last thread to signal More... | |
std::mutex | mutex_ |
mutex to synchronize access to the counters More... | |
size_t | step_ = 0 |
current counter used. More... | |
const size_t | thread_count_ |
number of threads More... | |
|
inlineexplicit |
Creates a new barrier that waits for n threads.
Definition at line 31 of file thread_barrier_mutex.hpp.
|
inline |
return generation step bit: 0 or 1
Definition at line 76 of file thread_barrier_mutex.hpp.
References ThreadBarrierMutex::step_.
|
inline |
Waits for n threads to arrive.
This method blocks and returns as soon as n threads are waiting inside the method. Prior to continuing work, the lambda functor is called by the last thread entering the barrier.
Definition at line 42 of file thread_barrier_mutex.hpp.
References ThreadBarrierMutex::counts_, ThreadBarrierMutex::cv_, ThreadBarrierMutex::mutex_, ThreadBarrierMutex::step_, and ThreadBarrierMutex::thread_count_.
Referenced by tlx::parallel_mergesort_detail::parallel_sort_mwms_pu(), and ThreadBarrierMutex::wait_yield().
|
inline |
Waits for n threads to arrive.
Identical with wait() for ThreadBarrierMutex.
This method blocks and returns as soon as n threads are waiting inside the method. Prior to continuing work, the lambda functor is called by the last thread entering the barrier.
Definition at line 71 of file thread_barrier_mutex.hpp.
References ThreadBarrierMutex::wait().
|
protected |
two counters: switch between them every run.
Definition at line 91 of file thread_barrier_mutex.hpp.
Referenced by ThreadBarrierMutex::wait().
|
protected |
condition variable everyone waits on for the last thread to signal
Definition at line 88 of file thread_barrier_mutex.hpp.
Referenced by ThreadBarrierMutex::wait().
|
protected |
mutex to synchronize access to the counters
Definition at line 85 of file thread_barrier_mutex.hpp.
Referenced by ThreadBarrierMutex::wait().
|
protected |
current counter used.
Definition at line 94 of file thread_barrier_mutex.hpp.
Referenced by ThreadBarrierMutex::step(), and ThreadBarrierMutex::wait().
|
protected |
number of threads
Definition at line 82 of file thread_barrier_mutex.hpp.
Referenced by ThreadBarrierMutex::wait().