xref: /llvm-project/lldb/test/API/commands/gui/spawn-threads/main.cpp (revision 83695d45d62121ab306d0dc108b549d9056a2f28)
1 #include <iostream>
2 #include <thread>
3 #include <vector>
4 
5 #include "pseudo_barrier.h"
6 
7 pseudo_barrier_t barrier_inside;
8 
thread_func()9 void thread_func() { pseudo_barrier_wait(barrier_inside); }
10 
test_thread()11 void test_thread() {
12   std::vector<std::thread> thrs;
13   for (int i = 0; i < 5; i++)
14     thrs.push_back(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 
main()21 int main() {
22   pseudo_barrier_init(barrier_inside, 6);
23   test_thread();
24   return 0;
25 }
26