Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
ThreadedMessageQueue< T > Class Template ReferenceProvides a mechanism for exchanging messages between threads. More...
Inheritance diagram for ThreadedMessageQueue< T >:
Detailed Descriptiontemplate<class T>
|
Classes | |
class | ReceiverThread |
Pulls messages out of the queue and gives them to the specified callback. More... | |
class | ReceiverThreadBase |
Holds controller flags for the receiver thread to indicate exit conditions. More... | |
Public Member Functions | |
ThreadedMessageQueue () | |
Constructor. | |
~ThreadedMessageQueue () | |
Destructor, calls finishCallback(). | |
void | send (const T &msg) |
Adds a message to the queue. | |
template<class F > | |
void | for_each (const F &f) |
Applies the specified predicate to each of the messages (you can modify the queue value itself via pass-by-reference). | |
template<class F > | |
void | remove (const F &f) |
Applies the specified predicate to each of the message, removing those for which the predicate returns true. | |
void | remove (const T e) |
Removes an element from the queue. | |
size_t | size () const |
Returns number of messages in msgs. | |
void | clear () |
Clears any backlog. | |
const T & | front () const |
Returns the next message (does not remove from the queue), blocking until available. | |
void | pop () |
Removes the front message, if any. | |
template<typename F , typename C > | |
void | spawnCallback (F fn, C &cl) |
Spawns a thread to trigger a class member callback with each message - only a single receiver is supported, so this replaces any previous receiver. | |
void | stopCallback () |
Sends a thread cancellation to the receiver thread to halt processing. | |
void | finishCallback () |
Sets a flag to exit the receiver thread at the completion of the current callback. | |
void | finishQueue () |
Sets a flag that when the receiver gets to the end of the queue, it will exit. | |
Public Attributes | |
Thread::Lock | lock |
provides mutual exclusion on msgs operations and signal reception | |
Thread::Condition | signal |
connects notification of send() in receiver | |
std::list< T > | msgs |
unprocessed messages | |
ReceiverThreadBase * | receiver |
currently only a single receiver is supported | |
Private Member Functions | |
ThreadedMessageQueue (const ThreadedMessageQueue &o) | |
Do not call. | |
ThreadedMessageQueue & | operator= (const ThreadedMessageQueue &o) |
Do not call. |
ThreadedMessageQueue< T >::ThreadedMessageQueue | ( | ) |
Constructor.
Definition at line 16 of file ThreadedMessageQueue.h.
ThreadedMessageQueue< T >::~ThreadedMessageQueue | ( | ) |
Destructor, calls finishCallback().
Definition at line 19 of file ThreadedMessageQueue.h.
ThreadedMessageQueue< T >::ThreadedMessageQueue | ( | const ThreadedMessageQueue< T > & | o | ) | [private] |
Do not call.
void ThreadedMessageQueue< T >::clear | ( | ) |
Clears any backlog.
Definition at line 37 of file ThreadedMessageQueue.h.
void ThreadedMessageQueue< T >::finishCallback | ( | ) |
Sets a flag to exit the receiver thread at the completion of the current callback.
If no callback is active, cancels the receiver immediately -- doesn't wait for another message first
Definition at line 79 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::~ThreadedMessageQueue().
void ThreadedMessageQueue< T >::finishQueue | ( | ) |
Sets a flag that when the receiver gets to the end of the queue, it will exit.
If the receiver is already blocking at the end of the queue, stops the thread now
Definition at line 95 of file ThreadedMessageQueue.h.
Applies the specified predicate to each of the messages (you can modify the queue value itself via pass-by-reference).
Definition at line 25 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::for_each().
const T& ThreadedMessageQueue< T >::front | ( | ) | const |
Returns the next message (does not remove from the queue), blocking until available.
Definition at line 40 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< T >::ReceiverThread< F, C >::run().
ThreadedMessageQueue& ThreadedMessageQueue< T >::operator= | ( | const ThreadedMessageQueue< T > & | o | ) | [private] |
Do not call.
void ThreadedMessageQueue< T >::pop | ( | ) |
Removes the front message, if any.
Definition at line 48 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< T >::ReceiverThread< F, C >::run().
void ThreadedMessageQueue< T >::remove | ( | const T | e | ) |
Removes an element from the queue.
Definition at line 31 of file ThreadedMessageQueue.h.
Applies the specified predicate to each of the message, removing those for which the predicate returns true.
Definition at line 28 of file ThreadedMessageQueue.h.
Referenced by EventRouter::requeueEvent().
void ThreadedMessageQueue< T >::send | ( | const T & | msg | ) |
Adds a message to the queue.
Definition at line 22 of file ThreadedMessageQueue.h.
Referenced by EventRouter::queueEvent().
size_t ThreadedMessageQueue< T >::size | ( | ) | const |
Returns number of messages in msgs.
Definition at line 34 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< T >::ReceiverThread< F, C >::run().
void ThreadedMessageQueue< T >::spawnCallback | ( | F | fn, | |
C & | cl | |||
) |
Spawns a thread to trigger a class member callback with each message - only a single receiver is supported, so this replaces any previous receiver.
Definition at line 52 of file ThreadedMessageQueue.h.
void ThreadedMessageQueue< T >::stopCallback | ( | ) |
Sends a thread cancellation to the receiver thread to halt processing.
Definition at line 59 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::spawnCallback().
Thread::Lock ThreadedMessageQueue< T >::lock [mutable] |
provides mutual exclusion on msgs operations and signal reception
Definition at line 111 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::clear(), ThreadedMessageQueue< EventBase * >::finishCallback(), ThreadedMessageQueue< EventBase * >::finishQueue(), ThreadedMessageQueue< EventBase * >::front(), ThreadedMessageQueue< EventBase * >::pop(), ThreadedMessageQueue< EventBase * >::remove(), ThreadedMessageQueue< EventBase * >::send(), and ThreadedMessageQueue< EventBase * >::stopCallback().
std::list<T> ThreadedMessageQueue< T >::msgs |
unprocessed messages
Definition at line 113 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::clear(), ThreadedMessageQueue< EventBase * >::finishCallback(), ThreadedMessageQueue< EventBase * >::finishQueue(), ThreadedMessageQueue< EventBase * >::for_each(), ThreadedMessageQueue< EventBase * >::front(), ThreadedMessageQueue< EventBase * >::pop(), ThreadedMessageQueue< EventBase * >::remove(), ThreadedMessageQueue< EventBase * >::send(), and ThreadedMessageQueue< EventBase * >::size().
ReceiverThreadBase* ThreadedMessageQueue< T >::receiver |
currently only a single receiver is supported
Definition at line 150 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::finishCallback(), ThreadedMessageQueue< EventBase * >::finishQueue(), ThreadedMessageQueue< EventBase * >::spawnCallback(), and ThreadedMessageQueue< EventBase * >::stopCallback().
Thread::Condition ThreadedMessageQueue< T >::signal |
connects notification of send() in receiver
Definition at line 112 of file ThreadedMessageQueue.h.
Referenced by ThreadedMessageQueue< EventBase * >::front(), and ThreadedMessageQueue< EventBase * >::send().
Tekkotsu v5.1CVS |
Generated Mon May 9 04:59:17 2016 by Doxygen 1.6.3 |