|
reSIProcate/stack
9694
|
#include <ValueFifo.hxx>


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) |
| T | 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 &) | |
| ValueFifo & | operator= (const ValueFifo &) |
Private Attributes | |
| std::deque< T > | myList |
| CancelableTimerQueue< T > | myTimerQueue |
| unsigned long | myFifoSize |
| unsigned long | myTimerSize |
| resip::Mutex | myMutex |
| resip::Condition | myCondition |
Distinct from resip::Fifo; by value and has cancellable timers.
Definition at line 23 of file ValueFifo.hxx.
| typedef CancelableTimerQueue<T>::Id resip::ValueFifo< T >::TimerId |
Definition at line 26 of file ValueFifo.hxx.
| resip::ValueFifo< T >::ValueFifo | ( | const Data & | name | ) | [inline] |
Definition at line 28 of file ValueFifo.hxx.
:
myFifoSize(0),
myTimerSize(0)
{
}
| resip::ValueFifo< T >::~ValueFifo | ( | ) | [inline] |
Definition at line 34 of file ValueFifo.hxx.
{
}
| resip::ValueFifo< T >::ValueFifo | ( | const ValueFifo< T > & | ) | [private] |
| 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();
}

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

| virtual time_t resip::ValueFifo< T >::averageServiceTimeMicroSec | ( | ) | const [inline, virtual] |
| 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;
}
| void resip::ValueFifo< T >::clear | ( | void | ) | [inline] |
Definition at line 118 of file ValueFifo.hxx.
References resip::ValueFifo< T >::myFifoSize, resip::ValueFifo< T >::myList, resip::ValueFifo< T >::myMutex, resip::ValueFifo< T >::myTimerQueue, and resip::ValueFifo< T >::myTimerSize.
{
resip::Lock lock(myMutex);
myFifoSize = 0;
myTimerSize = 0;
myTimerQueue.clear();
myList.clear();
}
| 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;
}
| virtual time_t resip::ValueFifo< T >::expectedWaitTimeMilliSec | ( | ) | const [inline, virtual] |
| 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();
}

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

| virtual time_t resip::ValueFifo< T >::getTimeDepth | ( | ) | const [inline, virtual] |
| bool resip::ValueFifo< T >::messageAvailable | ( | ) | [inline] |
Definition at line 139 of file ValueFifo.hxx.
References resip::ValueFifo< T >::messageAvailableNoLock(), and resip::ValueFifo< T >::myMutex.
{
resip::Lock lock(myMutex);
return messageAvailableNoLock();
}

| bool resip::ValueFifo< T >::messageAvailableNoLock | ( | ) | [inline, private] |
Definition at line 166 of file ValueFifo.hxx.
References resip::ValueFifo< T >::myFifoSize, and resip::ValueFifo< T >::myTimerQueue.
Referenced by resip::ValueFifo< T >::getNext(), and resip::ValueFifo< T >::messageAvailable().
{
return myFifoSize > 0 || myTimerQueue.available();
}
| ValueFifo& resip::ValueFifo< T >::operator= | ( | const ValueFifo< T > & | ) | [private] |
| unsigned int resip::ValueFifo< T >::size | ( | ) | const [inline] |
Definition at line 128 of file ValueFifo.hxx.
References resip::ValueFifo< T >::myFifoSize, resip::ValueFifo< T >::myMutex, and resip::ValueFifo< T >::myTimerSize.
Referenced by resip::ValueFifo< T >::getCountDepth().
{
resip::Lock lock(myMutex);
return myFifoSize + myTimerSize;
}
| 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().
{
myCondition.signal();
}

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().
unsigned long resip::ValueFifo< T >::myFifoSize [private] |
Definition at line 180 of file ValueFifo.hxx.
Referenced by resip::ValueFifo< T >::add(), resip::ValueFifo< T >::clear(), resip::ValueFifo< T >::empty(), resip::ValueFifo< T >::getNext(), resip::ValueFifo< T >::messageAvailableNoLock(), and resip::ValueFifo< T >::size().
std::deque<T> resip::ValueFifo< T >::myList [private] |
Definition at line 176 of file ValueFifo.hxx.
Referenced by resip::ValueFifo< T >::add(), resip::ValueFifo< T >::clear(), and resip::ValueFifo< T >::getNext().
resip::Mutex resip::ValueFifo< T >::myMutex [mutable, private] |
Definition at line 183 of file ValueFifo.hxx.
Referenced by resip::ValueFifo< T >::add(), resip::ValueFifo< T >::addDelayMs(), resip::ValueFifo< T >::cancel(), resip::ValueFifo< T >::clear(), resip::ValueFifo< T >::getNext(), resip::ValueFifo< T >::messageAvailable(), and resip::ValueFifo< T >::size().
CancelableTimerQueue<T> resip::ValueFifo< T >::myTimerQueue [private] |
Definition at line 178 of file ValueFifo.hxx.
Referenced by resip::ValueFifo< T >::addDelayMs(), resip::ValueFifo< T >::cancel(), resip::ValueFifo< T >::clear(), resip::ValueFifo< T >::getNext(), and resip::ValueFifo< T >::messageAvailableNoLock().
unsigned long resip::ValueFifo< T >::myTimerSize [private] |
Definition at line 181 of file ValueFifo.hxx.
Referenced by resip::ValueFifo< T >::addDelayMs(), resip::ValueFifo< T >::cancel(), resip::ValueFifo< T >::clear(), resip::ValueFifo< T >::empty(), resip::ValueFifo< T >::getNext(), and resip::ValueFifo< T >::size().
1.7.5.1