|
reSIProcate/stack
9694
|
This class creates a thread in which to run one or more SipStacks. More...
#include <EventStackThread.hxx>


Public Member Functions | |
| EventStackThread (EventThreadInterruptor &si, FdPollGrp &pollGrp) | |
| EventStackThread (SipStack &stack, EventThreadInterruptor &si, FdPollGrp &pollGrp) | |
| virtual | ~EventStackThread () |
| void | addStack (SipStack &stack) |
| virtual void | thread () |
| virtual void | shutdown () |
Protected Member Functions | |
| virtual unsigned int | getTimeTillNextProcessMS () const |
| virtual void | afterProcess () |
Private Types | |
| typedef std::vector< SipStack * > | StackList |
Private Attributes | |
| StackList | mStacks |
| EventThreadInterruptor & | mIntr |
| FdPollGrp & | mPollGrp |
This class creates a thread in which to run one or more SipStacks.
The thread provides cycles to the stack(s). It provides cycles in 3 ways: 1. When socket-io is possible, the event-loop will directly invoke the registered callback. 2. Prior to waiting for events, getTimeTillNextProcessMS() is called on all stacks. 3. After waiting, processTimers() is called on all stacks.
This implementation improves on StackThread and IntrruptableStackThread, by using the epoll() based system call (if available) provided by the FdPoll class.
Note that this is different than the InterruptableStackThread and simple StackThread in that it doesn't use the buildFdSet()/process() flow.
You must register {si} as an AsyncProcessHandler on the stacks in order to use this class. The same {si} instance must be used for all stacks.
Definition at line 40 of file EventStackThread.hxx.
typedef std::vector<SipStack*> resip::EventStackThread::StackList [private] |
Definition at line 72 of file EventStackThread.hxx.
| EventStackThread::EventStackThread | ( | EventThreadInterruptor & | si, |
| FdPollGrp & | pollGrp | ||
| ) |
Definition at line 37 of file EventStackThread.cxx.
| EventStackThread::EventStackThread | ( | SipStack & | stack, |
| EventThreadInterruptor & | si, | ||
| FdPollGrp & | pollGrp | ||
| ) |
Definition at line 43 of file EventStackThread.cxx.
References addStack().

| EventStackThread::~EventStackThread | ( | ) | [virtual] |
Definition at line 51 of file EventStackThread.cxx.
{
//InfoLog (<< "EventStackThread::~EventStackThread()");
}
| void EventStackThread::addStack | ( | SipStack & | stack | ) |
Definition at line 57 of file EventStackThread.cxx.
References mStacks.
Referenced by resip::EventStackSimpleMgr::createStack(), and EventStackThread().
{
mStacks.push_back(&stack);
}
| void EventStackThread::afterProcess | ( | ) | [protected, virtual] |
| unsigned int EventStackThread::getTimeTillNextProcessMS | ( | ) | const [protected, virtual] |
| void EventStackThread::shutdown | ( | ) | [virtual] |
Reimplemented from resip::ThreadIf.
Definition at line 92 of file EventStackThread.cxx.
References resip::SelectInterruptor::interrupt(), and mIntr.
{
ThreadIf::shutdown();
mIntr.interrupt();
}

| void EventStackThread::thread | ( | ) | [virtual] |
Implements resip::ThreadIf.
Definition at line 63 of file EventStackThread.cxx.
References afterProcess(), getTimeTillNextProcessMS(), resip::SipStack::getTimeTillNextProcessMS(), InfoLog, resip::ThreadIf::isShutdown(), mPollGrp, mStacks, resip::SipStack::processTimers(), and resip::FdPollGrp::waitAndProcess().
{
while (!isShutdown())
{
unsigned waitMs = getTimeTillNextProcessMS();
if ( waitMs > INT_MAX )
waitMs = INT_MAX;
StackList::iterator it;
for ( it=mStacks.begin(); it!=mStacks.end(); ++it)
{
SipStack *ss = *it;
unsigned wms = ss->getTimeTillNextProcessMS();
if ( wms < waitMs )
waitMs = wms;
// NOTE: In theory, we could early-out when waitMs gets to zero
// but I fear the stack may depend upon doing real-work in the query.
}
mPollGrp.waitAndProcess((int)waitMs);
for ( it=mStacks.begin(); it!=mStacks.end(); ++it)
{
SipStack *ss = *it;
ss->processTimers();
}
afterProcess();
}
InfoLog (<< "Shutting down stack thread");
}

Definition at line 74 of file EventStackThread.hxx.
Referenced by shutdown().
FdPollGrp& resip::EventStackThread::mPollGrp [private] |
Definition at line 75 of file EventStackThread.hxx.
Referenced by thread().
StackList resip::EventStackThread::mStacks [private] |
Definition at line 73 of file EventStackThread.hxx.
Referenced by addStack(), and thread().
1.7.5.1