
#ifndef PLS_BARRIER_H
#define PLS_BARRIER_H

#include <pthread.h>

namespace pls {
namespace internal {
namespace base {

/**
 * Provides standard barrier behaviour.
 * `count` threads have to call `wait()` before any of the `wait()` calls returns,
 * thus blocking all threads until everyone reached the barrier.
 *
 * PORTABILITY:
 * Current implementation is based on pthreads.
 */
class barrier {
  pthread_barrier_t barrier_;

 public:
  explicit barrier(unsigned int count);
  ~barrier();

  void wait();
};

}
}
}

#endif //PLS_BARRIER_H
