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

This class is used to create a thread to run the SipStack in. More...

#include <InterruptableStackThread.hxx>

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

List of all members.

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

SipStackmStack
SelectInterruptormSelectInterruptor

Detailed Description

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.


Constructor & Destructor Documentation

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

Member Function Documentation

void InterruptableStackThread::buildFdSet ( FdSet fdset) [protected, virtual]

Definition at line 61 of file InterruptableStackThread.cxx.

Referenced by thread().

{
}
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]

Definition at line 73 of file InterruptableStackThread.cxx.

Referenced by thread().

{
}
void InterruptableStackThread::shutdown ( ) [virtual]

Reimplemented from resip::ThreadIf.

Definition at line 54 of file InterruptableStackThread.cxx.

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

Here is the call graph for this function:

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

Here is the call graph for this function:


Member Data Documentation

Definition at line 44 of file InterruptableStackThread.hxx.

Referenced by shutdown(), and thread().

Definition at line 43 of file InterruptableStackThread.hxx.

Referenced by thread().


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