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>

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Classes

class  NoThrow
 Overload discriminator class for TimerList. 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 are have their timeouts called.

Definition at line 40 of file gtimerlist.cpp.

References doTimeouts().


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::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().

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(), soonest(), and update().

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

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.

References result.

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

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(), and soonest().

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, G::DateTime::now(), and update().

Referenced by ~TimerList().

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


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5