18 #ifndef ION_PORT_BARRIER_H_
19 #define ION_PORT_BARRIER_H_
21 #if defined(ION_PLATFORM_WINDOWS)
27 #include "base/integral_types.h"
28 #include "base/macros.h"
43 explicit Barrier(uint32 thread_count);
48 bool IsValid()
const {
return is_valid_; }
54 #if defined(ION_PLATFORM_WINDOWS)
55 void WaitInternal(int32 increment, int32 limit, HANDLE turnstile);
59 const int32 thread_count_;
60 std::atomic<int32> wait_count_;
63 #elif defined(ION_PLATFORM_LINUX) || defined(ION_PLATFORM_QNX)
64 pthread_barrier_t barrier_;
68 std::atomic<int32> waiting_count_;
70 pthread_cond_t condition_;
72 pthread_cond_t exit_condition_;
73 pthread_mutex_t mutex_;
74 const int32 thread_count_;
81 DISALLOW_COPY_AND_ASSIGN(
Barrier);
87 #endif // ION_PORT_BARRIER_H_
The Barrier class defines a multi-thread barrier that allows N threads to synchronize execution...
void Wait()
Causes the current thread to wait at the barrier.
Barrier(uint32 thread_count)
Constructs an instance that will wait for thread_count threads.
bool IsValid() const
Returns true if a valid barrier was created by the constructor.