15 #include <vsg/core/Inherit.h>
17 #include <condition_variable>
26 explicit Barrier(uint32_t num_thread) :
27 _num_threads(num_thread),
37 std::unique_lock lock(_mutex);
38 if (++_num_arrived == _num_threads)
44 auto my_phase = _phase;
45 _cv.wait(lock, [
this, my_phase]() {
return this->_phase != my_phase; });
52 std::unique_lock lock(_mutex);
53 if (++_num_arrived == _num_threads)
69 const uint32_t _num_threads;
70 uint32_t _num_arrived;
74 std::condition_variable _cv;
Barrier provides a means for synchronizing multiple threads that all release together once specified ...
Definition: Barrier.h:24
void arrive_and_drop()
increment the arrived count and release the barrier if count matches number of threads to arrive,...
Definition: Barrier.h:50
void arrive_and_wait()
increment the arrived count and release the barrier if count matches number of threads to arrive othe...
Definition: Barrier.h:35