reSIProcate/stack  9694
Public Member Functions | Protected Member Functions | Private Types | Private Attributes
resip::EventStackThread Class Reference

This class creates a thread in which to run one or more SipStacks. More...

#include <EventStackThread.hxx>

Inheritance diagram for resip::EventStackThread:
Inheritance graph
[legend]
Collaboration diagram for resip::EventStackThread:
Collaboration graph
[legend]

List of all members.

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
EventThreadInterruptormIntr
FdPollGrpmPollGrp

Detailed Description

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.


Member Typedef Documentation

typedef std::vector<SipStack*> resip::EventStackThread::StackList [private]

Definition at line 72 of file EventStackThread.hxx.


Constructor & Destructor Documentation

EventStackThread::EventStackThread ( EventThreadInterruptor si,
FdPollGrp pollGrp 
)

Definition at line 37 of file EventStackThread.cxx.

   : mIntr(si), mPollGrp(pollGrp)
{
}
EventStackThread::EventStackThread ( SipStack stack,
EventThreadInterruptor si,
FdPollGrp pollGrp 
)

Definition at line 43 of file EventStackThread.cxx.

References addStack().

   : mIntr(si), mPollGrp(pollGrp)
{
    addStack(stack);
}

Here is the call graph for this function:

EventStackThread::~EventStackThread ( ) [virtual]

Definition at line 51 of file EventStackThread.cxx.

{
   //InfoLog (<< "EventStackThread::~EventStackThread()");
}

Member Function Documentation

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]

Definition at line 105 of file EventStackThread.cxx.

Referenced by thread().

{
}
unsigned int EventStackThread::getTimeTillNextProcessMS ( ) const [protected, virtual]

Definition at line 99 of file EventStackThread.cxx.

Referenced by thread().

{
   return 10000;
}
void EventStackThread::shutdown ( ) [virtual]

Reimplemented from resip::ThreadIf.

Definition at line 92 of file EventStackThread.cxx.

References resip::SelectInterruptor::interrupt(), and mIntr.

Here is the call graph for this function:

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");
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 74 of file EventStackThread.hxx.

Referenced by shutdown().

Definition at line 75 of file EventStackThread.hxx.

Referenced by thread().

Definition at line 73 of file EventStackThread.hxx.

Referenced by addStack(), and thread().


The documentation for this class was generated from the following files: