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:

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

## 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 40 of file gtimer.h.

## Constructor & Destructor Documentation

## ◆ TimerBase()

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

Constructor.

The ExceptionSink 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 103 of file gtimer.h.

## ◆ adjust()

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.

## ◆ cancelTimer()

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

Cancels the timer. Does nothing if not running.

Definition at line 94 of file gtimer.cpp.

## ◆ doTimeout()

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

Used by TimerList to execute the onTimeout() callback.

Definition at line 104 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.

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 83 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 70 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 64 of file gtimer.cpp.

## ◆ t()

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.

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

- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/gnet/gtimer.h
- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/gnet/gtimer.cpp