#include <atomic>
#include <thread>

typedef std::atomic<int> pseudo_barrier_t;

static inline void pseudo_barrier_wait(pseudo_barrier_t &barrier) {
  --barrier;
  while (barrier > 0)
    std::this_thread::yield();
}

static inline void pseudo_barrier_init(pseudo_barrier_t &barrier, int count) {
  barrier = count;
}

#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)

Revert "[test] Address TestConcurrentMany*.py flakiness on macOS"
Revert "[test] Address TestConcurrentMany*.py flakiness on macOS"

This reverts my change to pseudo_barrier.h which isn't necessary anymore
after Fred's fix to debugserver and caused TestThreadStepOut to fail.

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@370963 91177308-0d34-0410-b5e6-96231b3b80d8
