MADNESS 0.10.1
madness::Barrier Class Reference

#include <worldmutex.h>

Collaboration diagram for madness::Barrier:

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.
void register_thread (int id, std::atomic< bool > *pflag)
 Each thread calls this once before first use.

Private Attributes

const int nthread
AtomicInt nworking
std::atomic< bool > * pflags [MAX_NTHREAD]
std::atomic< bool > sense

Static Private Attributes

static const int MAX_NTHREAD = 128

Constructor & Destructor Documentation

◆ Barrier()

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

References nthread, nworking, and sense.

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_EXCEPTION, MADNESS_MEMORY_LOAD_BARRIER, MADNESS_MEMORY_STORE_BARRIER, MAX_NTHREAD, nthread, nworking, pflags, and sense.

◆ register_thread()

void madness::Barrier::register_thread ( int id,
std::atomic< 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 a thread-local atomic flag (probably in the thread's stack)

References MADNESS_EXCEPTION, MAX_NTHREAD, pflags, and sense.

Member Data Documentation

◆ MAX_NTHREAD

const int madness::Barrier::MAX_NTHREAD = 128
staticprivate

Referenced by enter(), and register_thread().

◆ nthread

const int madness::Barrier::nthread
private

Referenced by Barrier(), and enter().

◆ nworking

AtomicInt madness::Barrier::nworking
private

Referenced by Barrier(), and enter().

◆ pflags

std::atomic<bool>* madness::Barrier::pflags[MAX_NTHREAD]
private

Referenced by enter(), and register_thread().

◆ sense

std::atomic<bool> madness::Barrier::sense
private

Referenced by Barrier(), enter(), and register_thread().


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