MADNESS  version 0.9
Public Member Functions | List of all members
madness::DQueue< T > Class Template Reference

A thread safe, fast but simple doubled-ended queue. More...

#include <dqueue.h>

Inheritance diagram for madness::DQueue< T >:
Inheritance graph
[legend]
Collaboration diagram for madness::DQueue< T >:
Collaboration graph
[legend]

Public Member Functions

 DQueue (size_t hint=200000)
 
virtual ~DQueue ()
 
void push_front (const T &value)
 Insert value at front of queue. More...
 
void push_back (const T &value, int ncopy=1)
 Insert element at back of queue (default is just one copy) More...
 
template<typename opT >
void scan (opT &op)
 
int pop_front (int nmax, T *r, bool wait)
 Pop multiple values off the front of queue ... returns number popped ... might be zero. More...
 
std::pair< T, bool > pop_front (bool wait)
 Pop value off the front of queue. More...
 
size_t size () const
 
bool empty () const
 
const DQStatsget_stats () const
 

Detailed Description

template<typename T>
class madness::DQueue< T >

A thread safe, fast but simple doubled-ended queue.

Since the point is speed, the implementation is a circular buffer rather than a linked list so as to avoid the new/del overhead. It will grow as needed, but presently will not shrink. Had to modify STL API to make things thread safe.

It is now rather heavily specialized to its only use.

Constructor & Destructor Documentation

template<typename T>
madness::DQueue< T >::DQueue ( size_t  hint = 200000)
inline
template<typename T>
virtual madness::DQueue< T >::~DQueue ( )
inlinevirtual

Member Function Documentation

template<typename T>
bool madness::DQueue< T >::empty ( ) const
inline
template<typename T>
const DQStats& madness::DQueue< T >::get_stats ( ) const
inline
template<typename T>
int madness::DQueue< T >::pop_front ( int  nmax,
T *  r,
bool  wait 
)
inline

Pop multiple values off the front of queue ... returns number popped ... might be zero.

r must refer to an array of dimension at least nmax ... you are presently given no more than max(size()/64,1) values ... arbitrary choice.

multi-threaded tasks might cause fewer tasks to be taken

Referenced by madness::DQueue< madness::PoolTaskInterface * >::pop_front().

template<typename T>
std::pair<T,bool> madness::DQueue< T >::pop_front ( bool  wait)
inline

Pop value off the front of queue.

template<typename T>
void madness::DQueue< T >::push_back ( const T &  value,
int  ncopy = 1 
)
inline

Insert element at back of queue (default is just one copy)

template<typename T>
void madness::DQueue< T >::push_front ( const T &  value)
inline

Insert value at front of queue.

template<typename T>
template<typename opT >
void madness::DQueue< T >::scan ( opT &  op)
inline
template<typename T>
size_t madness::DQueue< T >::size ( ) const
inline

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