A (base) class for distributing items between n different threads. More...
#include <multi_queue.h>
Classes | |
struct | FreeList |
Public Types | |
typedef Detail::NodeBase * | ThreadId |
Public Member Functions | |
ThreadId | addThread () |
adds a new thread to the object | |
bool | hasItems (ThreadId &cId) const |
uint32 | maxThreads () const |
MultiQueue (uint32 m, const Deleter &d=Deleter()) | |
creates a new object for at most m threads | |
void | pop (ThreadId &cId) |
pops an item from the queue associated with the given thread | |
void | reserve (uint32 c) |
bool | tryConsume (ThreadId &cId, T &out) |
tries to consume an item | |
~MultiQueue () | |
destroys the object and all unconsumed items | |
Protected Types | |
typedef Detail::Node< T > | Node |
typedef Detail::NodeBase | NodeBase |
Protected Member Functions | |
Node * | allocate (uint32 maxR, const T &in) |
uint32 | maxQ () const |
void | publish (const T &in, const ThreadId &) |
concurrency-safe version of unsafePublish | |
void | publishRelaxed (NodeBase *n) |
Non-atomically adds n to the global queue. | |
void | unsafePublish (const T &in, const ThreadId &) |
publishes a new item | |
Private Member Functions | |
MultiQueue (const MultiQueue &) | |
MultiQueue & | operator= (const MultiQueue &) |
void | release (NodeBase *n) |
Private Attributes | |
Deleter | deleter_ |
FreeList | freeList_ |
NodeBase | head_ |
const uint32 | maxQ_ |
NodeBase::AtomicPtr | tail_ |
A (base) class for distributing items between n different threads.
Logically, the class maintains n queues, one for each involved thread. Threads must register themselves by calling addThread(). The returned handle has then to be used for publishing and consuming items.
Definition at line 57 of file multi_queue.h.
typedef Detail::Node<T> Clasp::mt::MultiQueue< T, Deleter >::Node [protected] |
Definition at line 59 of file multi_queue.h.
typedef Detail::NodeBase Clasp::mt::MultiQueue< T, Deleter >::NodeBase [protected] |
Definition at line 60 of file multi_queue.h.
typedef Detail::NodeBase* Clasp::mt::MultiQueue< T, Deleter >::ThreadId |
Definition at line 62 of file multi_queue.h.
Clasp::mt::MultiQueue< T, Deleter >::MultiQueue | ( | uint32 | m, |
const Deleter & | d = Deleter() |
||
) | [inline, explicit] |
creates a new object for at most m threads
Definition at line 64 of file multi_queue.h.
Clasp::mt::MultiQueue< T, Deleter >::~MultiQueue | ( | ) | [inline] |
destroys the object and all unconsumed items
Definition at line 75 of file multi_queue.h.
Clasp::mt::MultiQueue< T, Deleter >::MultiQueue | ( | const MultiQueue< T, Deleter > & | ) | [private] |
ThreadId Clasp::mt::MultiQueue< T, Deleter >::addThread | ( | ) | [inline] |
adds a new thread to the object
Definition at line 88 of file multi_queue.h.
Node* Clasp::mt::MultiQueue< T, Deleter >::allocate | ( | uint32 | maxR, |
const T & | in | ||
) | [inline, protected] |
Definition at line 162 of file multi_queue.h.
bool Clasp::mt::MultiQueue< T, Deleter >::hasItems | ( | ThreadId & | cId | ) | const [inline] |
Definition at line 93 of file multi_queue.h.
uint32 Clasp::mt::MultiQueue< T, Deleter >::maxQ | ( | ) | const [inline, protected] |
Definition at line 161 of file multi_queue.h.
uint32 Clasp::mt::MultiQueue< T, Deleter >::maxThreads | ( | ) | const [inline] |
Definition at line 67 of file multi_queue.h.
MultiQueue& Clasp::mt::MultiQueue< T, Deleter >::operator= | ( | const MultiQueue< T, Deleter > & | ) | [private] |
void Clasp::mt::MultiQueue< T, Deleter >::pop | ( | ThreadId & | cId | ) | [inline] |
pops an item from the queue associated with the given thread
Definition at line 115 of file multi_queue.h.
void Clasp::mt::MultiQueue< T, Deleter >::publish | ( | const T & | in, |
const ThreadId & | |||
) | [inline, protected] |
concurrency-safe version of unsafePublish
Definition at line 133 of file multi_queue.h.
void Clasp::mt::MultiQueue< T, Deleter >::publishRelaxed | ( | NodeBase * | n | ) | [inline, protected] |
Non-atomically adds n to the global queue.
Definition at line 157 of file multi_queue.h.
void Clasp::mt::MultiQueue< T, Deleter >::release | ( | NodeBase * | n | ) | [inline, private] |
Definition at line 215 of file multi_queue.h.
void Clasp::mt::MultiQueue< T, Deleter >::reserve | ( | uint32 | c | ) | [inline] |
Definition at line 68 of file multi_queue.h.
bool Clasp::mt::MultiQueue< T, Deleter >::tryConsume | ( | ThreadId & | cId, |
T & | out | ||
) | [inline] |
tries to consume an item
Definition at line 100 of file multi_queue.h.
void Clasp::mt::MultiQueue< T, Deleter >::unsafePublish | ( | const T & | in, |
const ThreadId & | |||
) | [inline, protected] |
publishes a new item
Definition at line 127 of file multi_queue.h.
Deleter Clasp::mt::MultiQueue< T, Deleter >::deleter_ [private] |
Definition at line 226 of file multi_queue.h.
FreeList Clasp::mt::MultiQueue< T, Deleter >::freeList_ [private] |
Definition at line 224 of file multi_queue.h.
NodeBase Clasp::mt::MultiQueue< T, Deleter >::head_ [private] |
Definition at line 222 of file multi_queue.h.
const uint32 Clasp::mt::MultiQueue< T, Deleter >::maxQ_ [private] |
Definition at line 225 of file multi_queue.h.
NodeBase::AtomicPtr Clasp::mt::MultiQueue< T, Deleter >::tail_ [private] |
Definition at line 223 of file multi_queue.h.