Public Member Functions | Protected Member Functions | Protected Attributes

Threads::Barrier Class Reference

List of all members.

Public Member Functions

 Barrier (int nrthreads=-1, bool immediatrelease=true)
void setNrThreads (int)
int nrThreads () const
bool waitForAll (bool unlock=true)
void releaseAll ()
void releaseAllNoLock ()
Mutexmutex ()

Protected Member Functions

void releaseAllInternal ()

Protected Attributes

ConditionVar condvar_
int nrthreads_
int threadcount_
bool dorelease_
bool immediaterelease_

Detailed Description

Waits for a number of threads to reach a certain point (i.e. the call to Barrier::waitForAll). Once everyone has arrived, everyone is released.


Constructor & Destructor Documentation

Threads::Barrier::Barrier ( int  nrthreads = -1,
bool  immediatrelease = true 
)

Member Function Documentation

Mutex& Threads::Barrier::mutex (  )  [inline]
int Threads::Barrier::nrThreads (  )  const [inline]
void Threads::Barrier::releaseAll (  ) 

Locks, and releases all.

void Threads::Barrier::releaseAllInternal (  )  [protected]
void Threads::Barrier::releaseAllNoLock (  ) 

Releases all.

void Threads::Barrier::setNrThreads ( int   ) 
bool Threads::Barrier::waitForAll ( bool  unlock = true  ) 
Returns:
true if current thread is the first one to return. If immediaterelease_ is false, this thread has to release all other threads with releaseAll() or releaseAllNoLock().
Parameters:
unlock If false, the mutex will still be locked when returning, and mutex().unLock() must be called to allow other threads to be released().

Member Data Documentation

bool Threads::Barrier::dorelease_ [protected]