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
5 // avoids a lot of messy context switching to get multiple threads synchronized.
6 
7 typedef std::atomic<int> pseudo_barrier_t;
8 #define pseudo_barrier_wait(barrier)        \
9     do                                      \
10     {                                       \
11         --(barrier);                        \
12         while ((barrier).load() > 0)        \
13             ;                               \
14     } while (0)
15 
16 #define pseudo_barrier_init(barrier, count) \
17     do                                      \
18     {                                       \
19         (barrier) = (count);                \
20     } while (0)
21