18# include <sys/select.h>
50 const std::string&
name_);
111 : m_eh (
NULL), m_id (
"<unknown>")
113 trace(
"Timer::Timer");
122 trace(
"Timer::Timer(EH*, TV&)");
128 : m_eh (
t_.m_eh), m_timer (
t_.m_timer),
129 m_delta (
t_.m_delta), m_id (
t_.m_id)
131 trace(
"Timer::Timer(Timer&)");
138 trace(
"Timer::~Timer");
179 DL((
REACT,
"Timer %s (EH=%s) expires at %s (delta=%s)\n",
An abstract interface for handling I/O events, timers, and such.
#define trace(s)
trace() is used to trace function call chain in C++ program.
#define DL(X)
A macro for writing debug message to the Logger.
Class TimeVal is a wrapper around UNIX timeval structure.
A wrapper class to provide AutoPtr with reference semantics.
std::string get_id() const
Retrieve EventHandler ID.
string fmtString(const char *fmt_=NULL) const
Format timeval structure into readable format.
string fmt_mm_ss_mls() const
Format timeval structure in readable format MM:SS.MLS.
static TimeVal gettimeofday()
Shields off underlying OS differences in getting current time.
TimeVal m_timer
When the timer should be triggered.
EventHandler * m_eh
Pointer to EventHandler.
const TimeVal & getDeltaTime() const
Get Delta time.
~Timer()
Destructor: do-nothing.
bool operator<(const Timer &t_) const
Less-that by time.
bool operator==(const Timer &t_) const
Equal by time.
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Timer()
Default constructor.
Timer & operator=(const Timer &t_)
Assignment operator.
void set_id(const std::string &id_)
Set Timer ID.
std::string m_id
Timer's ID.
std::string get_id() const
Retrieve Timer ID.
const TimeVal & getExpirationTime() const
Get Expiration Time.
void dump(void)
Dump contents to logfile.
void rescheduleExpirationTime()
Reschedule expiration time with Delta value.
EventHandler * getHandler() const
Get EventHandler pointer.
@ REACT
Class Reactor/PrioriyQueue messages
TimerCompare class compares two Timers base on their expiration timestamp.
bool operator()(const Timer *t1_, const Timer *t2_) const