libassa
3.5.1
|
#include <TimerQueue.h>
Public Member Functions | |
TimerQueue () | |
Constructor. More... | |
~TimerQueue () | |
Destructor. More... | |
bool | isEmpty () |
Is queue empty? More... | |
TimerId | insert (EventHandler *eh_, const TimeVal &tv_, const TimeVal &delta_, const std::string &name_) |
Add timer (EventHandler object) to the queue to be dispatch at the time specified. More... | |
int | remove (EventHandler *eh_) |
Cancel all timers for the EventHandler eh_. More... | |
bool | remove (TimerId tid_) |
Cancel timer. More... | |
int | expire (const TimeVal &tv_) |
Traverse the queue, triggering all timers that are past argument timeval. More... | |
TimeVal & | top (void) |
Return expiration time of the top element in the queue. More... | |
void | dump (void) |
Dump Queue information to the log file. More... | |
Private Attributes | |
PriorityQueue< Timer *, TimerCompare > | m_queue |
Timer queue itself. More... | |
Definition at line 35 of file TimerQueue.h.
|
inline |
Constructor.
Definition at line 102 of file TimerQueue.h.
References trace.
TimerQueue::~TimerQueue | ( | ) |
Destructor.
Definition at line 19 of file TimerQueue.cpp.
References m_queue, ASSA::REACTTRACE, and trace_with_mask.
void TimerQueue::dump | ( | void | ) |
Dump Queue information to the log file.
Definition at line 151 of file TimerQueue.cpp.
References DL, m_queue, ASSA::REACT, and trace.
Referenced by ASSA::Reactor::calculateTimeout(), ASSA::Reactor::registerTimerHandler(), and ASSA::Reactor::removeTimerHandler().
int TimerQueue::expire | ( | const TimeVal & | tv_ | ) |
Traverse the queue, triggering all timers that are past argument timeval.
Timer(s) are then removed from the queue.
tv_ | Expiration time |
Reschedule without deleting the Timer object so that application-level code can still hold to the valid TimerId.
Definition at line 88 of file TimerQueue.cpp.
References DL, ASSA::Timer::dump(), ASSA::TimeVal::fmtString(), ASSA::Timer::get_id(), ASSA::Timer::getExpirationTime(), ASSA::Timer::getHandler(), ASSA::EventHandler::handle_timeout(), m_queue, ASSA::REACT, ASSA::REACTTRACE, ASSA::TRACE, and trace_with_mask.
Referenced by ASSA::Reactor::dispatch(), and ASSA::Reactor::waitForEvents().
TimerId TimerQueue::insert | ( | EventHandler * | eh_, |
const TimeVal & | tv_, | ||
const TimeVal & | delta_, | ||
const std::string & | name_ | ||
) |
Add timer (EventHandler object) to the queue to be dispatch at the time specified.
eh_ | Pointer to Event Handler that will be called when timer expires. |
tv_ | Absolute expiration time. |
delta_ | Relative timeout value. |
name_ | Name of the timer (for easy identification). |
Definition at line 137 of file TimerQueue.cpp.
References m_queue, and trace.
Referenced by ASSA::Reactor::registerTimerHandler().
|
inline |
Is queue empty?
Definition at line 109 of file TimerQueue.h.
References m_queue.
Referenced by ASSA::Reactor::calculateTimeout().
int TimerQueue::remove | ( | EventHandler * | eh_ | ) |
Cancel all timers for the EventHandler eh_.
eh_ | Pointer to Event Handler. |
Definition at line 30 of file TimerQueue.cpp.
References DL, m_queue, ASSA::REACT, ASSA::REACTTRACE, and trace_with_mask.
Referenced by ASSA::Reactor::removeHandler(), and ASSA::Reactor::removeTimerHandler().
bool TimerQueue::remove | ( | TimerId | tid_ | ) |
Cancel timer.
tid_ | Timer id. |
Definition at line 67 of file TimerQueue.cpp.
References DL, m_queue, ASSA::REACTTRACE, and trace_with_mask.
|
inline |
Return expiration time of the top element in the queue.
Definition at line 116 of file TimerQueue.h.
References m_queue.
Referenced by ASSA::Reactor::calculateTimeout().
|
private |
Timer queue itself.
Definition at line 94 of file TimerQueue.h.
Referenced by dump(), expire(), insert(), isEmpty(), remove(), top(), and ~TimerQueue().