reSIProcate/stack  9694
Public Types | Public Member Functions | Private Member Functions | Private Attributes
resip::ValueFifo< T > Class Template Reference

#include <ValueFifo.hxx>

Inheritance diagram for resip::ValueFifo< T >:
Inheritance graph
[legend]
Collaboration diagram for resip::ValueFifo< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef CancelableTimerQueue
< T >::Id 
TimerId

Public Member Functions

 ValueFifo (const Data &name)
 ~ValueFifo ()
void add (const T &t)
TimerId addDelayMs (const T &t, int offsetInMs)
bool cancel (TimerId id)
getNext ()
void clear ()
unsigned int size () const
bool empty () const
bool messageAvailable ()
virtual size_t getCountDepth () const
virtual time_t getTimeDepth () const
virtual time_t expectedWaitTimeMilliSec () const
virtual time_t averageServiceTimeMicroSec () const

Private Member Functions

bool messageAvailableNoLock ()
void wakeup ()
 ValueFifo (const ValueFifo &)
ValueFifooperator= (const ValueFifo &)

Private Attributes

std::deque< T > myList
CancelableTimerQueue< T > myTimerQueue
unsigned long myFifoSize
unsigned long myTimerSize
resip::Mutex myMutex
resip::Condition myCondition

Detailed Description

template<class T>
class resip::ValueFifo< T >

Distinct from resip::Fifo; by value and has cancellable timers.

Definition at line 23 of file ValueFifo.hxx.


Member Typedef Documentation

template<class T >
typedef CancelableTimerQueue<T>::Id resip::ValueFifo< T >::TimerId

Definition at line 26 of file ValueFifo.hxx.


Constructor & Destructor Documentation

template<class T >
resip::ValueFifo< T >::ValueFifo ( const Data name) [inline]

Definition at line 28 of file ValueFifo.hxx.

                                  :
         myFifoSize(0), 
         myTimerSize(0) 
      {
      }
template<class T >
resip::ValueFifo< T >::~ValueFifo ( ) [inline]

Definition at line 34 of file ValueFifo.hxx.

      {
      }
template<class T >
resip::ValueFifo< T >::ValueFifo ( const ValueFifo< T > &  ) [private]

Member Function Documentation

template<class T >
void resip::ValueFifo< T >::add ( const T &  t) [inline]

Definition at line 38 of file ValueFifo.hxx.

References resip::ValueFifo< T >::myFifoSize, resip::ValueFifo< T >::myList, resip::ValueFifo< T >::myMutex, and resip::ValueFifo< T >::wakeup().

      {
         resip::Lock lock(myMutex);
         myList.push_back(t);
         myFifoSize++;
         wakeup();
      }

Here is the call graph for this function:

template<class T >
TimerId resip::ValueFifo< T >::addDelayMs ( const T &  t,
int  offsetInMs 
) [inline]

Definition at line 46 of file ValueFifo.hxx.

References resip::ValueFifo< T >::myMutex, resip::ValueFifo< T >::myTimerQueue, resip::ValueFifo< T >::myTimerSize, and resip::ValueFifo< T >::wakeup().

      {
         resip::Lock lock(myMutex);
         if (offsetInMs < 0)
         {
            offsetInMs = 0;
         }

         bool doWakeup = false;
         if (myTimerQueue.empty() ||
             offsetInMs < myTimerQueue.getTimeout())
         {
            doWakeup = true;
         }

         TimerId id = myTimerQueue.addRelative(t, offsetInMs);
         myTimerSize++;

         //wakeup if new timer is sooner than next timer that would have
         //fired, or no timer set
         if (doWakeup)
         {

            wakeup();
         }
         return id;
      }

Here is the call graph for this function:

template<class T >
virtual time_t resip::ValueFifo< T >::averageServiceTimeMicroSec ( ) const [inline, virtual]

Implements resip::FifoStatsInterface.

Definition at line 160 of file ValueFifo.hxx.

      {
         return 1;
      }
template<class T >
bool resip::ValueFifo< T >::cancel ( TimerId  id) [inline]

Definition at line 74 of file ValueFifo.hxx.

References resip::ValueFifo< T >::myMutex, resip::ValueFifo< T >::myTimerQueue, and resip::ValueFifo< T >::myTimerSize.

      {
         resip::Lock lock(myMutex);
         if (myTimerQueue.cancel(id))
         {
            myTimerSize--;
            return true;
         }
         return false;
      }
template<class T >
void resip::ValueFifo< T >::clear ( void  ) [inline]
template<class T >
bool resip::ValueFifo< T >::empty ( ) const [inline]

Definition at line 134 of file ValueFifo.hxx.

References resip::ValueFifo< T >::myFifoSize, and resip::ValueFifo< T >::myTimerSize.

      {
         return myFifoSize + myTimerSize == 0;
      }
template<class T >
virtual time_t resip::ValueFifo< T >::expectedWaitTimeMilliSec ( ) const [inline, virtual]

Implements resip::FifoStatsInterface.

Definition at line 155 of file ValueFifo.hxx.

      {
         return 0;
      }
template<class T >
virtual size_t resip::ValueFifo< T >::getCountDepth ( ) const [inline, virtual]

Implements resip::FifoStatsInterface.

Definition at line 145 of file ValueFifo.hxx.

References resip::ValueFifo< T >::size().

      {
         return size();
      }

Here is the call graph for this function:

template<class T >
T resip::ValueFifo< T >::getNext ( ) [inline]

Definition at line 85 of file ValueFifo.hxx.

References resip::ValueFifo< T >::messageAvailableNoLock(), resip::ValueFifo< T >::myCondition, resip::ValueFifo< T >::myFifoSize, resip::ValueFifo< T >::myList, resip::ValueFifo< T >::myMutex, resip::ValueFifo< T >::myTimerQueue, resip::ValueFifo< T >::myTimerSize, and resip::Condition::wait().

      {
         resip::Lock lock(myMutex);

         while (!messageAvailableNoLock())
         {
            if (myTimerQueue.empty())
            {
               myCondition.wait(&myMutex);
            }
            else
            {
               myCondition.wait(&myMutex, myTimerQueue.getTimeout());
            }            
         }

         while (myTimerQueue.available())
         {
            myList.push_back(myTimerQueue.getNext());
            myFifoSize++;
            myTimerSize--;
         }

         assert (myFifoSize > 0);
         assert (!myList.empty());
         
         T firstMessage = myList.front();
         
         myList.pop_front(); //dcm -- should do this with a guard to avoid extra copy
         myFifoSize--;
         return firstMessage;
      }

Here is the call graph for this function:

template<class T >
virtual time_t resip::ValueFifo< T >::getTimeDepth ( ) const [inline, virtual]

Implements resip::FifoStatsInterface.

Definition at line 150 of file ValueFifo.hxx.

      {
         return 0;
      }
template<class T >
bool resip::ValueFifo< T >::messageAvailable ( ) [inline]

Definition at line 139 of file ValueFifo.hxx.

References resip::ValueFifo< T >::messageAvailableNoLock(), and resip::ValueFifo< T >::myMutex.

Here is the call graph for this function:

template<class T >
bool resip::ValueFifo< T >::messageAvailableNoLock ( ) [inline, private]
template<class T >
ValueFifo& resip::ValueFifo< T >::operator= ( const ValueFifo< T > &  ) [private]
template<class T >
unsigned int resip::ValueFifo< T >::size ( ) const [inline]
template<class T >
void resip::ValueFifo< T >::wakeup ( ) [inline, private]

Definition at line 171 of file ValueFifo.hxx.

References resip::ValueFifo< T >::myCondition, and resip::Condition::signal().

Referenced by resip::ValueFifo< T >::add(), and resip::ValueFifo< T >::addDelayMs().

Here is the call graph for this function:


Member Data Documentation

template<class T >
resip::Condition resip::ValueFifo< T >::myCondition [private]

Definition at line 184 of file ValueFifo.hxx.

Referenced by resip::ValueFifo< T >::getNext(), and resip::ValueFifo< T >::wakeup().

template<class T >
unsigned long resip::ValueFifo< T >::myFifoSize [private]
template<class T >
std::deque<T> resip::ValueFifo< T >::myList [private]
template<class T >
resip::Mutex resip::ValueFifo< T >::myMutex [mutable, private]
template<class T >
CancelableTimerQueue<T> resip::ValueFifo< T >::myTimerQueue [private]
template<class T >
unsigned long resip::ValueFifo< T >::myTimerSize [private]

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