36 #ifndef MADNESS_WORLD_DQUEUE_H__INCLUDED 
   37 #define MADNESS_WORLD_DQUEUE_H__INCLUDED 
   59                 : npush_back(0), npush_front(0), npop_front(0), ngrow(0), nmax(0) {}
 
   74         volatile size_t n __attribute__((aligned(64)));        
 
   76         volatile T* 
volatile buf;        
 
   84             if (sz != n) 
MADNESS_EXCEPTION(
"assertion failure in dqueue::grow", static_cast<int>(sz));
 
   88             else if (sz <= 1048576)
 
   92             volatile T* 
volatile nbuf = 
new T[sz];
 
   93             int lo = sz/2 - oldsz/2;
 
   94             for (
int i=_front; i<int(oldsz); ++i,++lo) {
 
   98                 for (
int i=0; i<=_back; ++i,++lo) {
 
  102             _front = sz/2 - oldsz/2;
 
  103             _back = _front + n - 1;
 
  108         void sanity_check()
 const {
 
  110             int num = _back - _front + 1;
 
  111             if (num < 0) num += sz;
 
  112             if (num==
int(sz) && n==0) num=0;
 
  113             if (num==0 && n==sz) num=sz;
 
  115             MADNESS_ASSERT(
long(n) == num);
 
  118         void push_back_with_lock(
const T& value) {
 
  126             if (nn > stats.
nmax) stats.
nmax = nn;
 
  130             if (b >= 
int(ss)) b = 0;
 
  142                 , sz(hint>2 ? hint : 2)
 
  163             if (nn > stats.
nmax) stats.
nmax = nn;
 
  167             if (f < 0) f = ss - 1;
 
  182                 push_back_with_lock(value);
 
  187         template <
typename opT>
 
  194             std::cout << 
"IN Q " << nn << std::endl;
 
  197                 T* p = 
const_cast<T*
>(buf + 
f);
 
  200                 if (f >= size) f = 0;
 
  244                 if (f >= 
int(thesize)) f = 0;
 
  254                         if (f >= 
int(thesize)) f = 0;
 
  274             return std::pair<T,bool>(r,ngot==1);
 
  292 #endif // MADNESS_WORLD_DQUEUE_H__INCLUDED 
Mutex that is applied/released at start/end of a scope. 
Definition: worldmutex.h:186
virtual ~DQueue()
Definition: dqueue.h:147
uint64_t npop_front
#calls to pop_front 
Definition: dqueue.h:54
const DQStats & get_stats() const 
Definition: dqueue.h:285
Simple wrapper for Pthread condition variable with its own mutex. 
Definition: worldmutex.h:566
int pop_front(int nmax, T *r, bool wait)
Pop multiple values off the front of queue ... returns number popped ... might be zero...
Definition: dqueue.h:210
void signal() const 
Definition: worldmutex.h:596
std::pair< T, bool > pop_front(bool wait)
Pop value off the front of queue. 
Definition: dqueue.h:271
DQueue(size_t hint=200000)
Definition: dqueue.h:140
void push_back(const T &value, int ncopy=1)
Insert element at back of queue (default is just one copy) 
Definition: dqueue.h:178
bool empty() const 
Definition: dqueue.h:281
NDIM & f
Definition: mra.h:2179
void push_front(const T &value)
Insert value at front of queue. 
Definition: dqueue.h:152
void scan(opT &op)
Definition: dqueue.h:188
void wait() const 
You should have acquired the mutex before entering here. 
Definition: worldmutex.h:592
DQStats()
Definition: dqueue.h:58
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
#define max(a, b)
Definition: lda.h:53
A thread safe, fast but simple doubled-ended queue. 
Definition: dqueue.h:72
const mpreal min(const mpreal &x, const mpreal &y)
Definition: mpreal.h:2675
Implements Mutex, MutexFair, Spinlock, ConditionVariable. 
uint64_t ngrow
#calls to grow 
Definition: dqueue.h:55
uint64_t npush_front
#calls to push_front 
Definition: dqueue.h:53
size_t size() const 
Definition: dqueue.h:277
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
uint64_t npush_back
#calls to push_back 
Definition: dqueue.h:52
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
uint64_t nmax
Lifetime max. entries in the queue. 
Definition: dqueue.h:56
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces. 
Definition: chem/atomutil.cc:45
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79