MADNESS
version 0.9
|
A thread safe, fast but simple doubled-ended queue. More...
#include <dqueue.h>
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 DQStats & | get_stats () const |
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.
|
inline |
|
inlinevirtual |
|
inline |
|
inline |
|
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().
|
inline |
Pop value off the front of queue.
|
inline |
Insert element at back of queue (default is just one copy)
|
inline |
Insert value at front of queue.
Referenced by madness::ThreadPool::scan().
|
inline |
Referenced by madness::DQueue< madness::PoolTaskInterface * >::scan().