E-MailRelay
|
An interface used by GNet::TimerList to keep track of pending timeouts and to deliver timeout events. More...
#include <gtimer.h>
Public Member Functions | |
virtual | ~TimerBase () |
Destructor. More... | |
void | startTimer (unsigned int interval_s, unsigned int interval_us=0U) |
Starts or restarts the timer so that it expires after the given interval. More... | |
void | startTimer (const G::TimeInterval &) |
Starts or restarts the timer so that it expires after the given interval. More... | |
void | cancelTimer () |
Cancels the timer. Does nothing if not running. More... | |
bool | active () const noexcept |
Returns true if the timer is started and not cancelled. More... | |
bool | immediate () const |
Used by TimerList. More... | |
void | doTimeout () |
Used by TimerList to execute the onTimeout() callback. More... | |
G::TimerTime | t () const |
Used by TimerList to get the expiry epoch time. More... | |
void | adjust (unsigned int us) |
Used by TimerList to set the fractional part of the expiry time of immediate() timers so that t() is ordered by startTimer() time. More... | |
bool | expired (G::TimerTime &) const |
Used by TimerList. More... | |
TimerBase (const TimerBase &)=delete | |
TimerBase (TimerBase &&)=delete | |
void | operator= (const TimerBase &)=delete |
void | operator= (TimerBase &&)=delete |
Protected Member Functions | |
TimerBase (ExceptionSink es) | |
Constructor. More... | |
virtual void | onTimeout ()=0 |
Called when the timer expires (or soon after). | |
An interface used by GNet::TimerList to keep track of pending timeouts and to deliver timeout events.
The public methods to start and cancel the timer are normally used via GNet::Timer<>.
|
explicitprotected |
Constructor.
The ExceptionSink receives an onException() call if the onTimeout() implementation throws.
Definition at line 29 of file gtimer.cpp.
|
virtual |
Destructor.
Definition at line 35 of file gtimer.cpp.
|
inlinenoexcept |
void GNet::TimerBase::adjust | ( | unsigned int | us | ) |
Used by TimerList to set the fractional part of the expiry time of immediate() timers so that t() is ordered by startTimer() time.
Definition at line 88 of file gtimer.cpp.
void GNet::TimerBase::cancelTimer | ( | ) |
Cancels the timer. Does nothing if not running.
Definition at line 94 of file gtimer.cpp.
void GNet::TimerBase::doTimeout | ( | ) |
Used by TimerList to execute the onTimeout() callback.
Definition at line 104 of file gtimer.cpp.
bool GNet::TimerBase::expired | ( | G::TimerTime & | now | ) | const |
Used by TimerList.
Returns true if expired when compared to the given epoch time.
Definition at line 47 of file gtimer.cpp.
bool GNet::TimerBase::immediate | ( | ) | const |
Used by TimerList.
Returns true if the timer is active() and zero-length.
Definition at line 83 of file gtimer.cpp.
void GNet::TimerBase::startTimer | ( | const G::TimeInterval & | i | ) |
Starts or restarts the timer so that it expires after the given interval.
Definition at line 70 of file gtimer.cpp.
void GNet::TimerBase::startTimer | ( | unsigned int | interval_s, |
unsigned int | interval_us = 0U |
||
) |
Starts or restarts the timer so that it expires after the given interval.
Definition at line 64 of file gtimer.cpp.
G::TimerTime GNet::TimerBase::t | ( | ) | const |
Used by TimerList to get the expiry epoch time.
Zero-length timers return a value corresponding to some time in ancient history (1970).
Definition at line 111 of file gtimer.cpp.