- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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

A timer base class that calls a pure virtual method on expiry. More...

`#include <gtimer.h>`

Inheritance diagram for GNet::AbstractTimer:

## Public Member Functions
virtual | ~AbstractTimer ()
| Destructor. More...
void | startTimer (unsigned int time)
| Starts the timer. More...
void | cancelTimer ()
| Cancels the timer. More...

## Protected Member Functions
| AbstractTimer ()
| Default constructor. More...
virtual void | onTimeout ()=0
| Called when the timer expires (or soon after). More...
virtual void | onTimeoutException (std::exception &)=0
| Called by the event loop when the onTimeout() override throws. More...

## Friends
class | TimerList

## Detailed Description

A timer base class that calls a pure virtual method on expiry.

Definition at line 41 of file gtimer.h.

## Constructor & Destructor Documentation

GNet::AbstractTimer::~AbstractTimer | ( |  | ) |
| virtual

Destructor.

Definition at line 58 of file gtimer.cpp.

References GNet::TimerList::instance(), and GNet::TimerList::remove().

GNet::AbstractTimer::AbstractTimer | ( |  | ) |
| protected

Default constructor.

Definition at line 49 of file gtimer.cpp.

References GNet::TimerList::add(), GNet::EventLoop::exists(), G_ASSERT, and GNet::TimerList::instance().

## Member Function Documentation

void GNet::AbstractTimer::cancelTimer | ( |  | ) |

Cancels the timer.

Definition at line 81 of file gtimer.cpp.

virtual void GNet::AbstractTimer::onTimeout | ( |  | ) |
| protected pure virtual

Called when the timer expires (or soon after).

Implemented in GSmtp::ClientProtocol, GSmtp::ServerProtocol, GNet::Timer< T >, GNet::Timer< GNet::ServerPeer >, GNet::Timer< GNet::Client >, GNet::Timer< GSmtp::RequestClient >, GNet::Timer< GNet::HeapClient >, GNet::Timer< GSmtp::SpamClient >, and GNet::Timer< GNet::SocketProtocolImp >.

virtual void GNet::AbstractTimer::onTimeoutException | ( | std::exception & |  | ) |
| protected pure virtual

Called by the event loop when the onTimeout() override throws.

The implementation can just throw the current exception so that the event loop terminates.

Implemented in GSmtp::ClientProtocol, GSmtp::ServerProtocol, GNet::Timer< T >, GNet::Timer< GNet::ServerPeer >, GNet::Timer< GNet::Client >, GNet::Timer< GSmtp::RequestClient >, GNet::Timer< GNet::HeapClient >, GNet::Timer< GSmtp::SpamClient >, and GNet::Timer< GNet::SocketProtocolImp >.

void GNet::AbstractTimer::startTimer | ( | unsigned int | time | ) |

Starts the timer.

Definition at line 74 of file gtimer.cpp.

References G::DateTime::now().

## Friends And Related Function Documentation

friend class TimerList
| friend

Definition at line 72 of file gtimer.h.

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

- gtimer.h
- gtimer.cpp