reSIProcate/rutil  9694
Public Types | Public Member Functions | Private Member Functions | Private Attributes
resip::Fifo< Msg > Class Template Reference

A templated, threadsafe message-queue class. More...

#include <Fifo.hxx>

Inheritance diagram for resip::Fifo< Msg >:
Inheritance graph
[legend]
Collaboration diagram for resip::Fifo< Msg >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef AbstractFifo< Msg * >
::Messages 
Messages

Public Member Functions

 Fifo (AsyncProcessHandler *interruptor=0)
virtual ~Fifo ()
size_t add (Msg *msg)
 Add a message to the fifo.
size_t addMultiple (Messages &msgs)
Msg * getNext ()
 Returns the first message available.
Msg * getNext (int ms)
 Returns the next message available.
void getMultiple (Messages &other, unsigned int max)
bool getMultiple (int ms, Messages &other, unsigned int max)
virtual void clear ()
 delete all elements in the queue
void setInterruptor (AsyncProcessHandler *interruptor)

Private Member Functions

 Fifo (const Fifo &rhs)
Fifooperator= (const Fifo &rhs)

Private Attributes

AsyncProcessHandlermInterruptor

Detailed Description

template<class Msg>
class resip::Fifo< Msg >

A templated, threadsafe message-queue class.

Definition at line 15 of file Fifo.hxx.


Member Typedef Documentation

template<class Msg>
typedef AbstractFifo<Msg*>::Messages resip::Fifo< Msg >::Messages

Reimplemented from resip::AbstractFifo< Msg * >.

Definition at line 30 of file Fifo.hxx.


Constructor & Destructor Documentation

template<class Msg >
resip::Fifo< Msg >::Fifo ( AsyncProcessHandler interruptor = 0)

Definition at line 66 of file Fifo.hxx.

                                                : 
   AbstractFifo<Msg*>(),
   mInterruptor(interruptor)
{
}
template<class Msg >
resip::Fifo< Msg >::~Fifo ( ) [virtual]

Definition at line 73 of file Fifo.hxx.

{
   clear();
}
template<class Msg>
resip::Fifo< Msg >::Fifo ( const Fifo< Msg > &  rhs) [private]

Member Function Documentation

template<class Msg>
size_t resip::Fifo< Msg >::add ( Msg *  msg)

Add a message to the fifo.

Definition at line 102 of file Fifo.hxx.

References resip::AbstractFifo< T >::add().

Referenced by resip::DnsStub::clearDnsCache(), resip::DnsStub::getDnsCacheDump(), resip::DnsStub::logDnsCache(), resip::DnsStub::lookup(), and resip::DnsStub::setEnumSuffixes().

{
   size_t size = AbstractFifo<Msg*>::add(msg);
   if(size==1 && mInterruptor)
   {
      // Only do this when the queue goes from empty to not empty.
      mInterruptor->handleProcessNotification();
   }
   return size;
}

Here is the call graph for this function:

template<class Msg >
size_t resip::Fifo< Msg >::addMultiple ( Messages msgs)

Definition at line 115 of file Fifo.hxx.

References resip::AbstractFifo< T >::addMultiple().

Referenced by resip::ProducerFifoBuffer< T >::flush().

{
   size_t inSize = msgs.size();
   size_t size = AbstractFifo<Msg*>::addMultiple(msgs);
   if(size==inSize && mInterruptor)
   {
      // Only do this when the queue goes from empty to not empty.
      mInterruptor->handleProcessNotification();
   }
   return size;
}

Here is the call graph for this function:

template<class Msg >
void resip::Fifo< Msg >::clear ( ) [virtual]

delete all elements in the queue

Reimplemented from resip::AbstractFifo< Msg * >.

Definition at line 89 of file Fifo.hxx.

{
   Lock lock(mMutex); (void)lock;
   while ( ! mFifo.empty() )
   {
      delete mFifo.front();
      mFifo.pop_front();
   }
   assert(mFifo.empty());
}
template<class Msg >
void resip::Fifo< Msg >::getMultiple ( Messages other,
unsigned int  max 
)

Definition at line 145 of file Fifo.hxx.

References resip::AbstractFifo< T >::getMultiple().

Referenced by resip::ConsumerFifoBuffer< T >::getNext().

Here is the call graph for this function:

template<class Msg >
bool resip::Fifo< Msg >::getMultiple ( int  ms,
Messages other,
unsigned int  max 
)

Definition at line 152 of file Fifo.hxx.

References resip::AbstractFifo< T >::getMultiple().

{
   return AbstractFifo<Msg*>::getMultiple(ms, other, max);
}

Here is the call graph for this function:

template<class Msg >
Msg * resip::Fifo< Msg >::getNext ( )

Returns the first message available.

It will wait if no messages are available. If a signal interrupts the wait, it will retry the wait. Signals can therefore not be caught via getNext. If you need to detect a signal, use block prior to calling getNext.

Reimplemented from resip::AbstractFifo< Msg * >.

Definition at line 129 of file Fifo.hxx.

References resip::AbstractFifo< T >::getNext().

Referenced by main(), and resip::DnsStub::processFifo().

Here is the call graph for this function:

template<class Msg >
Msg * resip::Fifo< Msg >::getNext ( int  ms)

Returns the next message available.

Will wait up to ms milliseconds if no information is available. If the specified time passes or a signal interrupts the wait, this method returns 0. This interface provides no mechanism to distinguish between timeout and interrupt.

Definition at line 136 of file Fifo.hxx.

References resip::AbstractFifo< T >::getNext().

{
   Msg* result(0);
   AbstractFifo<Msg*>::getNext(ms, result);
   return result;
}

Here is the call graph for this function:

template<class Msg>
Fifo& resip::Fifo< Msg >::operator= ( const Fifo< Msg > &  rhs) [private]
template<class Msg >
void resip::Fifo< Msg >::setInterruptor ( AsyncProcessHandler interruptor)

Definition at line 80 of file Fifo.hxx.

{
   Lock lock(mMutex); (void)lock;
   mInterruptor=interruptor;
}

Member Data Documentation

template<class Msg>
AsyncProcessHandler* resip::Fifo< Msg >::mInterruptor [private]

Definition at line 59 of file Fifo.hxx.


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