#include <thread_barrier.h>
Definition at line 47 of file thread_barrier.h.
◆ ThreadBarrier()
dart::ThreadBarrier::ThreadBarrier |
( |
intptr_t |
num_threads, |
|
|
intptr_t |
initial = 0 |
|
) |
| |
|
inlineexplicit |
Definition at line 49 of file thread_barrier.h.
50 : ref_count_(num_threads),
51 monitor_(),
52 participating_(initial),
53 remaining_(initial),
54 generation_(0) {}
◆ Release()
void dart::ThreadBarrier::Release |
( |
| ) |
|
|
inline |
Definition at line 83 of file thread_barrier.h.
83 {
84 intptr_t old = ref_count_.fetch_sub(1, std::memory_order_acq_rel);
86 if (old == 1) {
87 delete this;
88 }
89 }
◆ Sync()
void dart::ThreadBarrier::Sync |
( |
| ) |
|
|
inline |
Definition at line 66 of file thread_barrier.h.
66 {
67 MonitorLocker ml(&monitor_);
68 const intptr_t g = generation_;
69 remaining_--;
70 if (remaining_ == 0) {
71
72 generation_++;
73 remaining_ = participating_;
74 ml.NotifyAll();
75 } else {
76
77 while (g == generation_) {
78 ml.Wait();
79 }
80 }
81 }
◆ TryEnter()
bool dart::ThreadBarrier::TryEnter |
( |
| ) |
|
|
inline |
Definition at line 56 of file thread_barrier.h.
56 {
57 MonitorLocker ml(&monitor_);
58 if (generation_ != 0) {
59 return false;
60 }
61 remaining_++;
62 participating_++;
63 return true;
64 }
The documentation for this class was generated from the following file: