1#ifndef RESIP_AbstractFifo_hxx
2#define RESIP_AbstractFifo_hxx
110#define RESIP_FIFO_NOWAIT -1
111#define RESIP_FIFO_FOREVER 0
151 return mFifo.empty();
161 virtual unsigned int size()
const
164 return (
unsigned int)
mFifo.size();
175 return !
mFifo.empty();
222 while (
mFifo.empty())
229 T firstMessage(
mFifo.front());
259 toReturn =
mFifo.front();
265 const auto begin = std::chrono::steady_clock::now();
266 const auto end = begin + std::chrono::milliseconds(ms);
271 while (
mFifo.empty())
277 auto now = std::chrono::steady_clock::now();
284 bool signaled =
mCondition.wait_until(lock, end) == std::cv_status::no_timeout;
293 toReturn=
mFifo.front();
306 while (
mFifo.empty())
313 std::swap(
mFifo, other);
321 other.push_back(
mFifo.front());
337 const auto begin = std::chrono::steady_clock::now();
338 const auto end = begin + std::chrono::milliseconds(ms);
343 while (
mFifo.empty())
349 const auto now = std::chrono::steady_clock::now();
356 bool signaled =
mCondition.wait_until(lock, end) == std::cv_status::no_timeout;
365 std::swap(
mFifo, other);
373 other.push_back(
mFifo.front());
384 mFifo.push_back(item);
393 size_t size=items.size();
396 std::swap(
mFifo, items);
402 while(!items.empty())
404 mFifo.push_back(items.front());
#define resip_assert(x)
This file needs to work for both C and C++ code.
The base class from which various templated Fifo classes are derived.
virtual void onFifoPolled()
uint64_t mLastSampleTakenMicroSec
bool getMultiple(int ms, Messages &other, unsigned int max)
bool getNext(int ms, T &toReturn)
Returns the next message available.
virtual time_t getTimeDepth() const
computes the time delta between the oldest and newest queue members
uint32_t mAverageServiceTimeMicroSec
virtual time_t expectedWaitTimeMilliSec() const
Returns the expected time it will take to service all messages currently in the queue (in milli-secon...
virtual unsigned int size() const
get the current size of the fifo.
virtual void onMessagePopped(unsigned int num=1)
Called when a message (or messages) are removed from this fifo.
Condition mCondition
condition for waiting on new queue items
T getNext()
Returns the first message available.
bool messageAvailable() const
is a message available?
bool empty() const
is the queue empty?
size_t add(const T &item)
size_t addMultiple(Messages &items)
virtual void clear()
remove all elements in the queue (or not)
virtual size_t getCountDepth() const
Returns the number of elements in the FIFO.
AbstractFifo()
Constructor.
Messages mFifo
container for FIFO items
virtual time_t averageServiceTimeMicroSec() const
Returns the average time it takes for individual messages to be serviced (in micro-seconds)
void getMultiple(Messages &other, unsigned int max)
Mutex mMutex
access serialization lock
virtual void onMessagePushed(int num)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Interface for providing metrics on FIFOs, primarily used by CongestionManager.
virtual time_t averageServiceTimeMicroSec() const =0
Returns the average time it takes for individual messages to be serviced (in micro-seconds)
virtual const resip::Data & getDescription() const
Gets the description for this fifo.
void setDescription(const resip::Data &description)
Sets the description for this fifo.
virtual time_t getTimeDepth() const =0
Returns the difference in time between the youngest and oldest item in the FIFO in seconds.
virtual ~FifoStatsInterface()
virtual size_t getCountDepth() const =0
Returns the number of elements in the FIFO.
virtual time_t expectedWaitTimeMilliSec() const =0
Returns the expected time it will take to service all messages currently in the queue (in milli-secon...
void setRole(uint8_t role)
static uint64_t getTimeMicroSec()
Returns the current clock time in microseconds.
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
const _Tp1 resipIntDiv(const _Tp1 &__a, const _Tp2 &__b)
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...
unsigned long long uint64_t
std::condition_variable Condition
A condition variable that can be signaled or waited on, wraps POSIX/Windows implementations depending...