52 outstandingThreads(0),
55 pthread_cond_init(&
cond,NULL);
56 pthread_mutex_init(&
mutex,NULL);
65 pthread_cond_destroy(&
cond);
66 pthread_mutex_destroy(&
mutex);
121 pthread_mutex_lock(&
mutex);
123 clock_gettime(CLOCK_REALTIME,&
ts);
125 int reason = pthread_cond_timedwait(&
cond,&
mutex,&
ts);
126 if ( ETIMEDOUT == reason )
128 n_printf(
"PosixThreadBarrier::Wait() timed out!\n");
142 pthread_cond_broadcast(&
cond);
Block until all thread have arrived at the barrier.
Definition posixthreadbarrier_cond.h:19
pthread_mutex_t mutex
Definition posixthreadbarrier_cond.h:41
volatile long outstandingThreads
Definition posixthreadbarrier.h:38
long numThreads
Definition posixthreadbarrier.h:37
void Setup(SizeT numThreads)
setup the object with the number of threads
timespec ts
Definition posixthreadbarrier_cond.h:43
pthread_cond_t cond
Definition posixthreadbarrier_cond.h:40
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
~PosixThreadBarrier()
destructor
bool IsValid() const
return true if the object has been setup
Threading::CriticalSection critSect
Definition posixthreadbarrier.h:36
PosixThreadBarrier()
constructor
bool isValid
Definition posixthreadbarrier.h:40
void SignalContinue()
call after Arrive() returns true to resume all threads
Critical section objects are used to protect a portion of code from parallel execution.
void __cdecl n_printf(const char *msg,...)
Nebula's printf replacement.
Definition debug.cc:209
#define n_assert(exp)
Definition debug.h:50
Posix implemention of a read-many write-few lock.
Definition posixsysfunc.cc:21
Typedefs for the Timing subsystem.
int SizeT
Definition types.h:49