brintos

brintos / llvm-project-archived public Read only

0
0
Text · 788 B · e4066b7 Raw
22 lines · c
1#include <atomic>2 3// Note that although hogging the CPU while waiting for a variable to change4// would be terrible in production code, it's great for testing since it avoids5// a lot of messy context switching to get multiple threads synchronized.6 7typedef 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)22