MADNESS  0.10.1
Public Member Functions | Private Attributes | List of all members
madness::Barrier Class Reference

#include <worldmutex.h>

Collaboration diagram for madness::Barrier:
Collaboration graph
[legend]

Public Member Functions

 Barrier (int nthread)
 
bool enter (const int id)
 Each thread calls this with its id (0,..,nthread-1) to enter the barrier. More...
 
void register_thread (int id, volatile bool *pflag)
 Each thread calls this once before first use. More...
 

Private Attributes

const int nthread
 
AtomicInt nworking
 
volatile bool * pflags [128]
 
volatile bool sense
 

Constructor & Destructor Documentation

◆ Barrier()

madness::Barrier::Barrier ( int  nthread)
inline

References nthread, and nworking.

Member Function Documentation

◆ enter()

bool madness::Barrier::enter ( const int  id)
inline

Each thread calls this with its id (0,..,nthread-1) to enter the barrier.

The thread last to enter the barrier returns true. Others return false.

All calls to the barrier must use the same value of nthread.

References madness::cpu_relax(), madness::AtomicInt::dec_and_test(), MADNESS_EXCEPTION, nthread, nworking, pflags, and sense.

Referenced by madness::TaskThreadEnv::barrier().

◆ register_thread()

void madness::Barrier::register_thread ( int  id,
volatile bool *  pflag 
)
inline

Each thread calls this once before first use.

id should be the thread id (0,..,nthread-1) and pflag a pointer to thread-local bool (probably in the thread's stack)

References MADNESS_EXCEPTION, pflags, and sense.

Member Data Documentation

◆ nthread

const int madness::Barrier::nthread
private

Referenced by Barrier(), and enter().

◆ nworking

AtomicInt madness::Barrier::nworking
private

Referenced by Barrier(), and enter().

◆ pflags

volatile bool* madness::Barrier::pflags[128]
private

Referenced by enter(), and register_thread().

◆ sense

volatile bool madness::Barrier::sense
private

Referenced by enter(), and register_thread().


The documentation for this class was generated from the following file: