|
reSIProcate/rutil
9694
|
#include <TimeLimitFifo.hxx>


Public Types | |
| enum | DepthUsage { EnforceTimeDepth, IgnoreTimeDepth, InternalElement } |
Public Member Functions | |
| TimeLimitFifo (unsigned int maxDurationSecs, unsigned int maxSize) | |
| After it runs out of the lesser of these limits it will start to refuse messages. | |
| virtual | ~TimeLimitFifo () |
| bool | add (Msg *msg, DepthUsage usage) |
| Add a message to the fifo. | |
| Msg * | getNext () |
| Returns the first message available. | |
| Msg * | getNext (int ms) |
| Returns the first message available within a time limit. | |
| virtual time_t | timeDepth () const |
| Return the time depth of the queue. | |
| bool | wouldAccept (DepthUsage usage) const |
| would an add called now work? | |
| void | clear () |
| removes all items from the FIFO | |
| virtual size_t | getCountDepth () const |
| gets the depth of the FIFO | |
| virtual time_t | getTimeDepth () const |
| Return the time depth of the queue. | |
| virtual size_t | getCountDepthTolerance () const |
| returns the FIFO count depth tolerance | |
| virtual time_t | getTimeDepthTolerance () const |
| returns the FIFO time depth tolerance | |
| virtual void | setCountDepthTolerance (unsigned int max) |
| set the count depth tolerance of the FIFO | |
| virtual void | setTimeDepthTolerance (unsigned int maxSecs) |
| set the time depth tolerance of the FIFO | |
Private Member Functions | |
| time_t | timeDepthInternal () const |
| bool | wouldAcceptInteral (DepthUsage usage) const |
| TimeLimitFifo (const TimeLimitFifo &rhs) | |
| TimeLimitFifo & | operator= (const TimeLimitFifo &rhs) |
Private Attributes | |
| time_t | mMaxDurationSecs |
| unsigned int | mMaxSize |
| unsigned int | mUnreservedMaxSize |
Definition at line 91 of file TimeLimitFifo.hxx.
| enum resip::TimeLimitFifo::DepthUsage |
Definition at line 94 of file TimeLimitFifo.hxx.
| resip::TimeLimitFifo< Msg >::TimeLimitFifo | ( | unsigned int | maxDurationSecs, |
| unsigned int | maxSize | ||
| ) |
After it runs out of the lesser of these limits it will start to refuse messages.
Definition at line 221 of file TimeLimitFifo.hxx.
: AbstractFifo< Timestamped<Msg*> >(),
mMaxDurationSecs(maxDurationSecs),
mMaxSize(maxSize),
mUnreservedMaxSize((int)((maxSize*8)/10)) // !dlb! random guess
{}
| resip::TimeLimitFifo< Msg >::~TimeLimitFifo | ( | ) | [virtual] |
Definition at line 230 of file TimeLimitFifo.hxx.
| resip::TimeLimitFifo< Msg >::TimeLimitFifo | ( | const TimeLimitFifo< Msg > & | rhs | ) | [private] |
| bool resip::TimeLimitFifo< Msg >::add | ( | Msg * | msg, |
| DepthUsage | usage | ||
| ) |
Add a message to the fifo.
return true iff succeeds
| Msg* | 'Message pointer' |
| DepthUsage | : (Needs work...) EnforceTimeDepth -- external (non ACK) requests IgnoreTimeDepth -- external reponse and ACK InternalElement -- internal messages (timers, application postbacks..); use reserved queue space +------------------------------------------------------+ | | | | +------------------------------------------------------+ <-----enforce-------------------> <---------------ignoreTimeDepth------------> <--------------------- internalElement----------------> |
enforce will drop things that exceed the queue ignore will go past that limit to the extent of the queue (eg. internal will basically not drop anything
Definition at line 238 of file TimeLimitFifo.hxx.
Referenced by main(), and Producer::thread().
{
Lock lock(mMutex); (void)lock;
if (wouldAcceptInteral(usage))
{
time_t n = time(0);
mFifo.push_back(Timestamped<Msg*>(msg, n));
onMessagePushed(1);
mCondition.signal();
return true;
}
else
{
return false;
}
}
| void resip::TimeLimitFifo< Msg >::clear | ( | void | ) | [virtual] |
removes all items from the FIFO
Reimplemented from resip::AbstractFifo< Timestamped< Msg * > >.
Definition at line 346 of file TimeLimitFifo.hxx.
| size_t resip::TimeLimitFifo< Msg >::getCountDepth | ( | ) | const [virtual] |
gets the depth of the FIFO
Reimplemented from resip::AbstractFifo< Timestamped< Msg * > >.
Definition at line 359 of file TimeLimitFifo.hxx.
{
return size();
}
| size_t resip::TimeLimitFifo< Msg >::getCountDepthTolerance | ( | ) | const [virtual] |
returns the FIFO count depth tolerance
Definition at line 366 of file TimeLimitFifo.hxx.
{
return mUnreservedMaxSize;
}
| Msg * resip::TimeLimitFifo< Msg >::getNext | ( | ) |
Returns the first message available.
Reimplemented from resip::AbstractFifo< Timestamped< Msg * > >.
Definition at line 268 of file TimeLimitFifo.hxx.
References resip::Timestamped< Payload >::getMsg().
Referenced by main(), and Consumer::thread().
{
Timestamped<Msg*> tm(AbstractFifo< Timestamped<Msg*> >::getNext());
return tm.getMsg();
}

| Msg * resip::TimeLimitFifo< Msg >::getNext | ( | int | ms | ) |
Returns the first message available within a time limit.
| ms | the maximum amount of time to wait in milliseconds for a message |
Definition at line 276 of file TimeLimitFifo.hxx.
References resip::Timestamped< Payload >::getMsg().
{
Timestamped<Msg*> tm(0,0);
if(AbstractFifo< Timestamped<Msg*> >::getNext(ms, tm))
{
return tm.getMsg();
}
return 0;
}

| time_t resip::TimeLimitFifo< Msg >::getTimeDepth | ( | ) | const [virtual] |
Return the time depth of the queue.
Reimplemented from resip::AbstractFifo< Timestamped< Msg * > >.
Definition at line 373 of file TimeLimitFifo.hxx.
{
return timeDepth();
}
| time_t resip::TimeLimitFifo< Msg >::getTimeDepthTolerance | ( | ) | const [virtual] |
returns the FIFO time depth tolerance
Definition at line 380 of file TimeLimitFifo.hxx.
{
return mMaxDurationSecs;
}
| TimeLimitFifo& resip::TimeLimitFifo< Msg >::operator= | ( | const TimeLimitFifo< Msg > & | rhs | ) | [private] |
| void resip::TimeLimitFifo< Msg >::setCountDepthTolerance | ( | unsigned int | max | ) | [virtual] |
set the count depth tolerance of the FIFO
| max | the new count depth tolerance of the FIFO |
Definition at line 387 of file TimeLimitFifo.hxx.
{
Lock lock(mMutex); (void)lock;
mUnreservedMaxSize=int(maxCount * 0.8);
}
| void resip::TimeLimitFifo< Msg >::setTimeDepthTolerance | ( | unsigned int | maxSecs | ) | [virtual] |
set the time depth tolerance of the FIFO
| maxSec | the maximum time depth tolerance |
Definition at line 395 of file TimeLimitFifo.hxx.
{
Lock lock(mMutex); (void)lock;
mMaxDurationSecs=maxSecs;
}
| time_t resip::TimeLimitFifo< Msg >::timeDepth | ( | ) | const [virtual] |
Return the time depth of the queue.
Definition at line 338 of file TimeLimitFifo.hxx.
Referenced by main().
{
Lock lock(mMutex); (void)lock;
return timeDepthInternal();
}
| time_t resip::TimeLimitFifo< Msg >::timeDepthInternal | ( | ) | const [private] |
Definition at line 288 of file TimeLimitFifo.hxx.
| bool resip::TimeLimitFifo< Msg >::wouldAccept | ( | DepthUsage | usage | ) | const |
would an add called now work?
| usage | what depth policy should be used to determine if the call would work |
Definition at line 259 of file TimeLimitFifo.hxx.
Referenced by Producer::thread().
{
Lock lock(mMutex); (void)lock;
return wouldAcceptInteral(usage);
}
| bool resip::TimeLimitFifo< Msg >::wouldAcceptInteral | ( | DepthUsage | usage | ) | const [inline, private] |
Definition at line 300 of file TimeLimitFifo.hxx.
{
if ((mMaxSize != 0 &&
mFifo.size() >= mMaxSize))
{
return false;
}
if (usage == InternalElement)
{
return true;
}
if (mUnreservedMaxSize != 0 &&
mFifo.size() >= mUnreservedMaxSize)
{
return false;
}
if (usage == IgnoreTimeDepth)
{
return true;
}
assert(usage == EnforceTimeDepth);
if (mFifo.size() == 0 ||
mMaxDurationSecs == 0 ||
timeDepthInternal() < mMaxDurationSecs)
{
return true;
}
return false;
}
time_t resip::TimeLimitFifo< Msg >::mMaxDurationSecs [private] |
Definition at line 215 of file TimeLimitFifo.hxx.
unsigned int resip::TimeLimitFifo< Msg >::mMaxSize [private] |
Definition at line 216 of file TimeLimitFifo.hxx.
unsigned int resip::TimeLimitFifo< Msg >::mUnreservedMaxSize [private] |
Definition at line 217 of file TimeLimitFifo.hxx.
1.7.5.1