E-MailRelay

Public Member Functions | Protected Member Functions | List of all members
GNet::TimerBase Class Referenceabstract

An interface used by GNet::TimerList to keep track of pending timeouts and to deliver timeout events. More...

`#include <gtimer.h>`

Inheritance diagram for GNet::TimerBase:
[legend]

## 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...
const G::TimerTime & | tref () const noexcept
| An inline noexcept alternative to t(). More...
void | adjust (unsigned long)
| Used by TimerList to set the order of immedate() timer expiry. More...
bool | expired (G::TimerTime &) const
| Used by TimerList. More...
| TimerBase (const TimerBase &)=delete
| TimerBase (TimerBase &&)=delete
TimerBase & | operator= (const TimerBase &)=delete
TimerBase & | operator= (TimerBase &&)=delete

## Protected Member Functions
| TimerBase (EventState es)
| Constructor. More...
virtual void | onTimeout ()=0
| Called when the timer expires (or soon after).

## Detailed Description

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<>.

Definition at line 41 of file gtimer.h.

## Constructor & Destructor Documentation

## ◆ TimerBase()

GNet::TimerBase::TimerBase | ( | EventState | es | ) |
| explicit protected

Constructor.

The EventState receives an onException() call if the onTimeout() implementation throws.

Definition at line 29 of file gtimer.cpp.

## ◆ ~TimerBase()

GNet::TimerBase::~TimerBase | ( |  | ) |
| virtual

Destructor.

Definition at line 35 of file gtimer.cpp.

## Member Function Documentation

## ◆ active()

bool GNet::TimerBase::active | ( |  | ) | const
| inline noexcept

Returns true if the timer is started and not cancelled.

Definition at line 118 of file gtimer.h.

## ◆ adjust()

void GNet::TimerBase::adjust | ( | unsigned long | order | ) |

Used by TimerList to set the order of immedate() timer expiry.

Definition at line 90 of file gtimer.cpp.

## ◆ cancelTimer()

void GNet::TimerBase::cancelTimer | ( |  | ) |

Cancels the timer. Does nothing if not running.

Definition at line 96 of file gtimer.cpp.

## ◆ doTimeout()

void GNet::TimerBase::doTimeout | ( |  | ) |

Used by TimerList to execute the onTimeout() callback.

Definition at line 105 of file gtimer.cpp.

## ◆ expired()

bool GNet::TimerBase::expired | ( | G::TimerTime & | now | ) | const

Used by TimerList.

Returns true if expired when compared to the given epoch time. If the given epoch time is TimerTime::zero() then it is initialised with TimerTime::now().

Definition at line 47 of file gtimer.cpp.

## ◆ immediate()

bool GNet::TimerBase::immediate | ( |  | ) | const

Used by TimerList.

Returns true if the timer is active() and zero-length.

Definition at line 85 of file gtimer.cpp.

## ◆ startTimer() [1/2]

void GNet::TimerBase::startTimer | ( | const G::TimeInterval & | i | ) |

Starts or restarts the timer so that it expires after the given interval.

Definition at line 77 of file gtimer.cpp.

## ◆ startTimer() [2/2]

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 69 of file gtimer.cpp.

## ◆ t()

G::TimerTime GNet::TimerBase::t | ( |  | ) | const

Used by TimerList to get the expiry epoch time.

Zero-length timers return TimerTime::zero() plus any adjust()ment, ~guaranteed to be less than the t() of any non-immediate timer.

Definition at line 112 of file gtimer.cpp.

## ◆ tref()

const G::TimerTime & GNet::TimerBase::tref | ( |  | ) | const
| inline noexcept

An inline noexcept alternative to t().

Definition at line 112 of file gtimer.h.

The documentation for this class was generated from the following files:

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/gtimer.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/gtimer.cpp