|
reSIProcate
SIP stack, Dialog Usage Manager and related libraries
|
A generic thread-bank class. More...
#include <Dispatcher.hxx>
Public Member Functions | |
| Dispatcher (std::unique_ptr< Worker > prototype, resip::SipStack *stack, int workers=2, bool startImmediately=true) | |
| virtual | ~Dispatcher () |
| virtual bool | post (std::unique_ptr< resip::ApplicationMessage > &work) |
| Posts a message to this thread bank. | |
| size_t | fifoCountDepth () const |
| time_t | fifoTimeDepth () const |
| int | workPoolSize () const |
| void | stop () |
| This Dispatcher will stop accepting new work, but processing will continue normally on the messages already in the queue. | |
| void | resume () |
| Resumes accepting work. | |
| void | shutdownAll () |
| Shuts down the thread-bank. | |
| void | startAll () |
| Starts the thread bank. | |
Public Attributes | |
| resip::SipStack * | mStack |
Protected Attributes | |
| resip::TimeLimitFifo< resip::ApplicationMessage > | mFifo |
| bool | mAcceptingWork |
| bool | mShutdown |
| bool | mStarted |
| Worker * | mWorkerPrototype |
| resip::RWMutex | mMutex |
| std::vector< WorkerThread * > | mWorkerThreads |
A generic thread-bank class.
This is intended to be a generic thread-bank class that operates under the paradigm of accepting messages, modifying those messages, and posting the messages back to the originator through the SipStack. (Since this uses ApplicationMessages, the message will automatically get back to the correct TransactionUser; what happens from there is the coder's business.)
This class gets generality by using prototyping of a very simple class, Worker. All the user must do is subclass Worker to do the work needed, and pass an instance of this class when constructing the Dispatcher. Dispatcher will clone this Worker as many times as needed to fill the thread bank.
Definition at line 37 of file Dispatcher.hxx.
| resip::Dispatcher::Dispatcher | ( | std::unique_ptr< Worker > | prototype, |
| resip::SipStack * | stack, | ||
| int | workers = 2, |
||
| bool | startImmediately = true |
||
| ) |
| prototype | The prototypical instance of Worker. |
| stack | The stack to post messages to. |
| workers | The number of threads in this bank. |
| startImmediately | Whether to start this thread bank on construction. |
Definition at line 10 of file Dispatcher.cxx.
|
virtual |
Definition at line 32 of file Dispatcher.cxx.
| size_t resip::Dispatcher::fifoCountDepth | ( | ) | const |
Definition at line 72 of file Dispatcher.cxx.
| time_t resip::Dispatcher::fifoTimeDepth | ( | ) | const |
Definition at line 78 of file Dispatcher.cxx.
|
virtual |
Posts a message to this thread bank.
| work | The message that conveys the work that needs to be done. It is understood that any information that needs to be conveyed back to the originator will be placed in the message by the Workers in the thread bank. |
Definition at line 54 of file Dispatcher.cxx.
| void resip::Dispatcher::resume | ( | ) |
Resumes accepting work.
Definition at line 97 of file Dispatcher.cxx.
| void resip::Dispatcher::shutdownAll | ( | ) |
Shuts down the thread-bank.
Definition at line 104 of file Dispatcher.cxx.
| void resip::Dispatcher::startAll | ( | ) |
Starts the thread bank.
Definition at line 122 of file Dispatcher.cxx.
| void resip::Dispatcher::stop | ( | ) |
This Dispatcher will stop accepting new work, but processing will continue normally on the messages already in the queue.
Definition at line 90 of file Dispatcher.cxx.
| int resip::Dispatcher::workPoolSize | ( | ) | const |
Definition at line 84 of file Dispatcher.cxx.
|
protected |
Definition at line 116 of file Dispatcher.hxx.
|
protected |
Definition at line 115 of file Dispatcher.hxx.
|
protected |
Definition at line 121 of file Dispatcher.hxx.
|
protected |
Definition at line 117 of file Dispatcher.hxx.
| resip::SipStack* resip::Dispatcher::mStack |
Definition at line 110 of file Dispatcher.hxx.
|
protected |
Definition at line 118 of file Dispatcher.hxx.
|
protected |
Definition at line 119 of file Dispatcher.hxx.
|
protected |
Definition at line 123 of file Dispatcher.hxx.