Debian Codegraph @

lldb/packages/Python/lldbsuite/test/make/pseudo_barrier.h

raw
1 #include <atomic>
2
3 // Note that although hogging the CPU while waiting for a variable to change
4 // would be terrible in production code, it's great for testing since it avoids
5 // a lot of messy context switching to get multiple threads synchronized.
6
7 typedef std::atomic<int> pseudo_barrier_t;
8
9 #define pseudo_barrier_wait(barrier) \
10 do \
11 { \
12 --(barrier); \
13 while ((barrier).load() > 0) \
14 ; \
15 } while (0)
16
17 #define pseudo_barrier_init(barrier, count) \
18 do \
19 { \
20 (barrier) = (count); \
21 } while (0)