1 | #include <iostream> |
---|---|
2 | #include <thread> |
3 | #include <vector> |
4 | |
5 | #include "pseudo_barrier.h" |
6 | |
7 | pseudo_barrier_t barrier_inside; |
8 | |
9 | void thread_func() { pseudo_barrier_wait(barrier_inside); } |
10 | |
11 | void test_thread() { |
12 | std::vector<std::thread> thrs; |
13 | for (int i = 0; i < 5; i++) |
14 | thrs.push_back(x: std::thread(thread_func)); // break here |
15 | |
16 | pseudo_barrier_wait(barrier_inside); // break before join |
17 | for (auto &t : thrs) |
18 | t.join(); |
19 | } |
20 | |
21 | int main() { |
22 | pseudo_barrier_init(barrier_inside, 6); |
23 | test_thread(); |
24 | return 0; |
25 | } |
26 |