diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:04:10 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:04:10 +0000 |
| commit | 74a628f776edb588bff8f8f5cc16eac947c9d631 (patch) | |
| tree | dc32e010ac4902621e5a279bfeb48628f7f0e166 /packages/Python/lldbsuite/test/make/pseudo_barrier.h | |
| parent | afed7be32164a598f8172282c249af7266c48b46 (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/make/pseudo_barrier.h')
| -rw-r--r-- | packages/Python/lldbsuite/test/make/pseudo_barrier.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/make/pseudo_barrier.h b/packages/Python/lldbsuite/test/make/pseudo_barrier.h new file mode 100644 index 000000000000..592000ddea4d --- /dev/null +++ b/packages/Python/lldbsuite/test/make/pseudo_barrier.h @@ -0,0 +1,20 @@ +#include <atomic> + +// Note that although hogging the CPU while waiting for a variable to change +// would be terrible in production code, it's great for testing since it +// avoids a lot of messy context switching to get multiple threads synchronized. + +typedef std::atomic<int> pseudo_barrier_t; +#define pseudo_barrier_wait(barrier) \ + do \ + { \ + --(barrier); \ + while ((barrier).load() > 0) \ + ; \ + } while (0) + +#define pseudo_barrier_init(barrier, count) \ + do \ + { \ + (barrier) = (count); \ + } while (0) |
