36 #ifndef MADNESS_WORLD_WORLDDEP_H__INCLUDED
37 #define MADNESS_WORLD_WORLDDEP_H__INCLUDED
66 static const int MAXCALLBACKS = 8;
68 mutable volatile callbackT callbacks;
74 void do_callbacks(callbackT& cb)
const {
85 int ndep()
const {
return ndepend;}
98 const_cast<callbackT&
>(this->callbacks).push(callback);
100 cb =
const_cast<callbackT&
>(callbacks);
101 const_cast<callbackT&
>(callbacks).clear();
118 if (--ndepend == 0) {
119 cb =
const_cast<callbackT&
>(callbacks);
120 const_cast<callbackT&
>(callbacks).clear();
127 #ifdef MADNESS_ASSERTIONS_THROW
129 error(
"DependencyInterface::~DependencyInterface(): ndepend =", ndepend);
131 MADNESS_ASSERT(ndepend == 0);
137 #endif // MADNESS_WORLD_WORLDDEP_H__INCLUDED
Mutex that is applied/released at start/end of a scope.
Definition: worldmutex.h:186
void error(const char *msg)
Definition: world.cc:128
void inc()
Increment the number of dependencies.
Definition: worlddep.h:108
DependencyInterface(int ndep=0)
Definition: worlddep.h:82
void notify()
Invoked by callbacks to notifiy of dependencies being satisfied.
Definition: worlddep.h:91
This class used for callbacks (e.g., for dependency tracking)
Definition: worlddep.h:51
bool probe() const
Returns true if ndepend == 0.
Definition: worlddep.h:88
virtual ~DependencyInterface()
Definition: worlddep.h:126
bool empty() const
Definition: array.h:530
A simple, fixed-size, stack.
Definition: array.h:499
Provides interface for tracking dependencies.
Definition: worlddep.h:60
int ndep() const
Returns the number of unsatisfied dependencies.
Definition: worlddep.h:85
virtual ~CallbackInterface()
Definition: worlddep.h:55
T & pop()
Definition: array.h:512
Implements Mutex, MutexFair, Spinlock, ConditionVariable.
T & front()
Definition: array.h:517
Spinlock using pthread spinlock operations.
Definition: worldmutex.h:200
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
void dec()
Decrement the number of dependencies and invoke callback if ndepend=0.
Definition: worlddep.h:114
void register_callback(CallbackInterface *callback)
Registers a callback for when ndepend==0 , immediately invoked if ndepend==0.
Definition: worlddep.h:94