Nebula
|
#include <posixthreadbarrier.h>
Block until all thread have arrived at the barrier.
(C) 2013-2018 Individual contributors, see AUTHORS file
Public Member Functions | |
PosixThreadBarrier () | |
constructor | |
~PosixThreadBarrier () | |
destructor | |
void | Setup (SizeT numThreads) |
setup the object with the number of threads | |
bool | IsValid () const |
return true if the object has been setup | |
bool | Arrive () |
enter thread barrier, return false if not all threads have arrived yet | |
void | Wait () |
call after Arrive() returns false to wait for other threads | |
void | SignalContinue () |
call after Arrive() returns true to resume all threads | |
PosixThreadBarrier () | |
constructor | |
~PosixThreadBarrier () | |
destructor | |
void | Setup (SizeT numThreads) |
setup the object with the number of threads | |
bool | IsValid () const |
return true if the object has been setup | |
bool | Arrive () |
enter thread barrier, return false if not all threads have arrived yet | |
void | Wait () |
call after Arrive() returns false to wait for other threads | |
void | SignalContinue () |
call after Arrive() returns true to resume all threads | |
Private Attributes | |
Threading::CriticalSection | critSect |
long | numThreads |
volatile long | outstandingThreads |
sem_t * | semaphore |
bool | isValid |
pthread_cond_t | cond |
pthread_mutex_t | mutex |
timespec | ts |
|
inline |
constructor
|
inline |
destructor
Posix::PosixThreadBarrier::PosixThreadBarrier | ( | ) |
constructor
Posix::PosixThreadBarrier::~PosixThreadBarrier | ( | ) |
destructor
|
inline |
enter thread barrier, return false if not all threads have arrived yet
Notify arrival at thread-sync point, return false if not all threads have arrived yet, and true if all threads have arrived.
If the method returns false, you should immediately call Wait(), if the method returns true, the caller has a chance to perform some actions which should happen before threads continue, and then call the SignalContinue() method.
bool Posix::PosixThreadBarrier::Arrive | ( | ) |
enter thread barrier, return false if not all threads have arrived yet
|
inline |
return true if the object has been setup
bool Posix::PosixThreadBarrier::IsValid | ( | ) | const |
return true if the object has been setup
|
inline |
setup the object with the number of threads
void Posix::PosixThreadBarrier::Setup | ( | SizeT | numThreads | ) |
setup the object with the number of threads
|
inline |
void Posix::PosixThreadBarrier::SignalContinue | ( | ) |
call after Arrive() returns true to resume all threads
|
inline |
call after Arrive() returns false to wait for other threads
This method should be called when Arrive() returns false.
It will put the thread to sleep because not all threads have arrived yet. When the method returns, all threads have arrived at the sync point.
NOTE: sometimes both the render and the main thread arrive here with the outstandingThreads member set to 1 (from two) causing both thread to be waiting idefinitely.
void Posix::PosixThreadBarrier::Wait | ( | ) |
call after Arrive() returns false to wait for other threads
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |