Classes | Public Member Functions | Static Public Member Functions | List of all members
GNet::TimerList Class Reference

A singleton which maintains a list of all Timer objects, and interfaces to the event loop on their behalf. More...

#include <gtimerlist.h>

Classes

class  NoThrow
 Overload discriminator class for TimerList. More...
 

Public Member Functions

 TimerList ()
 Default constructor. More...
 
 ~TimerList ()
 Destructor. More...
 
void add (AbstractTimer &)
 Adds a timer. Used by Timer::Timer(). More...
 
void remove (AbstractTimer &)
 Removes a timer from the list. More...
 
void update (G::DateTime::EpochTime previous_soonest)
 Called when one of the list's timers has changed. More...
 
G::DateTime::EpochTime soonest () const
 Returns the time of the first timer to expire, or zero if none. More...
 
unsigned int interval (bool &infinite) const
 Returns the interval to the next timer expiry. More...
 
void doTimeouts ()
 Triggers the timeout callbacks of any expired timers. More...
 

Static Public Member Functions

static TimerListinstance (const NoThrow &)
 Singleton access. Returns NULL if none. More...
 
static TimerListinstance ()
 Singleton access. Throws an exception if none. More...
 

Detailed Description

A singleton which maintains a list of all Timer objects, and interfaces to the event loop on their behalf.

Definition at line 42 of file gtimerlist.h.

Constructor & Destructor Documentation

GNet::TimerList::TimerList ( )

Default constructor.

Definition at line 29 of file gtimerlist.cpp.

GNet::TimerList::~TimerList ( )

Destructor.

Any expired timers have their timeouts called.

Definition at line 40 of file gtimerlist.cpp.

Member Function Documentation

void GNet::TimerList::add ( AbstractTimer t)

Adds a timer. Used by Timer::Timer().

Definition at line 57 of file gtimerlist.cpp.

Referenced by GNet::AbstractTimer::AbstractTimer().

void GNet::TimerList::doTimeouts ( )

Triggers the timeout callbacks of any expired timers.

Called by the event loop (GNet::EventLoop).

Definition at line 169 of file gtimerlist.cpp.

References G_DEBUG, and G::DateTime::now().

GNet::TimerList * GNet::TimerList::instance ( const NoThrow )
static

Singleton access. Returns NULL if none.

Definition at line 156 of file gtimerlist.cpp.

GNet::TimerList & GNet::TimerList::instance ( )
static

Singleton access. Throws an exception if none.

Definition at line 161 of file gtimerlist.cpp.

Referenced by GNet::AbstractTimer::AbstractTimer(), GNet::TimerUpdate::TimerUpdate(), GNet::AbstractTimer::~AbstractTimer(), and GNet::TimerUpdate::~TimerUpdate().

unsigned int GNet::TimerList::interval ( bool &  infinite) const

Returns the interval to the next timer expiry.

The 'infinite' value is set to true if there are no timers running.

Definition at line 141 of file gtimerlist.cpp.

References G::DateTime::now().

void GNet::TimerList::remove ( AbstractTimer t)

Removes a timer from the list.

Used by Timer::~Timer().

Definition at line 63 of file gtimerlist.cpp.

Referenced by GNet::AbstractTimer::~AbstractTimer().

G::DateTime::EpochTime GNet::TimerList::soonest ( ) const

Returns the time of the first timer to expire, or zero if none.

Definition at line 104 of file gtimerlist.cpp.

Referenced by GNet::TimerUpdate::TimerUpdate().

void GNet::TimerList::update ( G::DateTime::EpochTime  previous_soonest)

Called when one of the list's timers has changed.

Definition at line 75 of file gtimerlist.cpp.

References GNet::EventLoop::exists(), G_DEBUG, GNet::EventLoop::instance(), GNet::EventLoop::setTimeout(), and update().

Referenced by update(), and GNet::TimerUpdate::~TimerUpdate().


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