|
reSIProcate/stack
9694
|
This class is used to create a thread to run the SipStack in. More...
#include <InterruptableStackThread.hxx>


Public Member Functions | |
| InterruptableStackThread (SipStack &stack, SelectInterruptor &si) | |
| virtual | ~InterruptableStackThread () |
| virtual void | thread () |
| virtual void | shutdown () |
Protected Member Functions | |
| virtual void | buildFdSet (FdSet &fdset) |
| virtual unsigned int | getTimeTillNextProcessMS () const |
| virtual void | process (FdSet &fdset) |
Private Attributes | |
| SipStack & | mStack |
| SelectInterruptor & | mSelectInterruptor |
This class is used to create a thread to run the SipStack in.
The thread provides cycles to the SipStack by calling process. Process is called when select returns a signaled file descriptor.
This implementation improves on StackThread, by providing a fully blocking architecture (ie. no need to wake up every 25ms), since posting to TransactionState will cause the SelectInterruptor to be invoked.
You must register SelectInterrupter as an AsyncProcessHandler on the SipStack in order to use this class. This is done by providing SelectInterrupter to the constructor of SipStack. This should be the same SelectInterrupter provided when constructing this class.
Definition at line 28 of file InterruptableStackThread.hxx.
| InterruptableStackThread::InterruptableStackThread | ( | SipStack & | stack, |
| SelectInterruptor & | si | ||
| ) |
Definition at line 11 of file InterruptableStackThread.cxx.
: mStack(stack), mSelectInterruptor(si) {}
| InterruptableStackThread::~InterruptableStackThread | ( | ) | [virtual] |
Definition at line 16 of file InterruptableStackThread.cxx.
{
//InfoLog (<< "InterruptableStackThread::~InterruptableStackThread()");
}
| void InterruptableStackThread::buildFdSet | ( | FdSet & | fdset | ) | [protected, virtual] |
| unsigned int InterruptableStackThread::getTimeTillNextProcessMS | ( | ) | const [protected, virtual] |
Definition at line 66 of file InterruptableStackThread.cxx.
Referenced by thread().
{
//.dcm. --- eventually make infinite
return 10000;
}
| void InterruptableStackThread::process | ( | FdSet & | fdset | ) | [protected, virtual] |
| void InterruptableStackThread::shutdown | ( | ) | [virtual] |
Reimplemented from resip::ThreadIf.
Definition at line 54 of file InterruptableStackThread.cxx.
References resip::SelectInterruptor::interrupt(), and mSelectInterruptor.
{
ThreadIf::shutdown();
mSelectInterruptor.interrupt();
}

| void InterruptableStackThread::thread | ( | ) | [virtual] |
Implements resip::ThreadIf.
Definition at line 22 of file InterruptableStackThread.cxx.
References resip::SelectInterruptor::buildFdSet(), buildFdSet(), resip::SipStack::buildFdSet(), ErrLog, getTimeTillNextProcessMS(), resip::SipStack::getTimeTillNextProcessMS(), InfoLog, resip::ThreadIf::isShutdown(), mSelectInterruptor, mStack, resip::SelectInterruptor::process(), process(), resip::SipStack::process(), resip::resipMin(), and resip::FdSet::selectMilliSeconds().
{
while (!isShutdown())
{
try
{
FdSet fdset;
mStack.process(fdset); // .dcm. reqd to get send requests queued at transports
mSelectInterruptor.buildFdSet(fdset);
mStack.buildFdSet(fdset);
buildFdSet(fdset);
int ret = fdset.selectMilliSeconds(resipMin(mStack.getTimeTillNextProcessMS(),
getTimeTillNextProcessMS()));
if (ret >= 0)
{
// .dlb. use return value to peak at the message to see if it is a
// shutdown, and call shutdown if it is
// .dcm. how will this interact w/ TuSelector?
mSelectInterruptor.process(fdset);
mStack.process(fdset);
process(fdset);
}
}
catch (BaseException& e)
{
ErrLog (<< "Unhandled exception: " << e);
}
}
InfoLog (<< "Shutting down stack thread");
}

Definition at line 44 of file InterruptableStackThread.hxx.
Referenced by shutdown(), and thread().
SipStack& resip::InterruptableStackThread::mStack [private] |
Definition at line 43 of file InterruptableStackThread.hxx.
Referenced by thread().
1.7.5.1