Ion
|
The Barrier class defines a multi-thread barrier that allows N threads to synchronize execution. More...
#include "barrier.h"
Public Member Functions | |
Barrier (uint32 thread_count) | |
Constructs an instance that will wait for thread_count threads. More... | |
~Barrier () | |
bool | IsValid () const |
Returns true if a valid barrier was created by the constructor. More... | |
void | Wait () |
Causes the current thread to wait at the barrier. More... | |
The Barrier class defines a multi-thread barrier that allows N threads to synchronize execution.
For example, if you create a Barrier for 3 threads and have each of the three threads call Wait() on it, then execution of each waiting thread will proceed once all 3 have called Wait().
|
explicit |
Constructs an instance that will wait for thread_count threads.
Linux and QNX are the only platforms that support barriers in pthreads.
If thread_count is not positive, the Barrier will do nothing and IsValid() will return false.
Both the windows and non-Linux/QNX implementations below may seem rather complex. This is because they guard against two potential errors:
Pthread barriers are an optional part of the Posix spec, and Mac, iOS, and Android do not support them, so this version is used on those platforms.
Definition at line 156 of file barrier.cc.
References IsValid().
ion::port::Barrier::~Barrier | ( | ) |
Definition at line 168 of file barrier.cc.
References IsValid().
|
inline |
void ion::port::Barrier::Wait | ( | ) |
Causes the current thread to wait at the barrier.
Definition at line 182 of file barrier.cc.
References IsValid().