OpendTect  7.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Threads::Barrier Class Reference

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. More...

Public Member Functions

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

Protected Member Functions

void releaseAllInternal ()
 

Protected Attributes

ConditionVar condvar_
 
bool dorelease_
 
bool immediaterelease_
 
int nrthreads_
 
int threadcount_
 

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

◆ Barrier()

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

Member Function Documentation

◆ mutex()

Mutex& Threads::Barrier::mutex ( )
inline

◆ nrThreads()

int Threads::Barrier::nrThreads ( ) const
inline

◆ releaseAll()

void Threads::Barrier::releaseAll ( )

Locks, and releases all.

◆ releaseAllInternal()

void Threads::Barrier::releaseAllInternal ( )
protected

◆ releaseAllNoLock()

void Threads::Barrier::releaseAllNoLock ( )

Releases all.

◆ setNrThreads()

void Threads::Barrier::setNrThreads ( int  )

◆ waitForAll()

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
unlockIf 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

◆ condvar_

ConditionVar Threads::Barrier::condvar_
protected

◆ dorelease_

bool Threads::Barrier::dorelease_
protected

◆ immediaterelease_

bool Threads::Barrier::immediaterelease_
protected

◆ nrthreads_

int Threads::Barrier::nrthreads_
protected

◆ threadcount_

int Threads::Barrier::threadcount_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2024