Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members  

Timer Class Reference

#include <Timer.h>

Inheritance diagram for Timer:

Cancelable Runnable TimerThread List of all members.

Public Methods

 Timer (bool reuseKeys=true) throw (Synchronization_Exception)
virtual ~Timer () throw ()
unsigned long addEvent (unsigned long, bool periodic=false) throw (Synchronization_Exception)
bool delEvent (unsigned long) throw (Synchronization_Exception)
virtual void run () throw ()

Static Public Methods

unsigned long now () throw ()

Protected Types

typedef RecursiveInstanceLock LockPolicy
 Locking policy.

typedef std::set< TimerEventEventList
 Event list.

typedef std::deque< int > KeyList
 ID list.


Protected Attributes

EventList _events
 Registered events.

KeyList _keys
 Used ids.

unsigned long _next
 Next id.

bool _reuseKeys
 Key reuse flag.

Condition _interrupt
 Condition.


Detailed Description

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-05-26T09:19:32-0400>
Version:
2.1.4
This class defines a simple Timer object base. Other objects can be derived from this class to create more specialzed Timers. This encapsulates the timing routines and doesn't force a Timer to have to deal directly with a thread.

Interest in a timer is manipulated using the inherited Observable methods


Constructor & Destructor Documentation

Timer bool    reuseKeys = true throw (Synchronization_Exception)
 

Create a new Timer object.

Parameters:
reuseKeys  If true, then the keys this Timer generates can be reused as events expire. If false, then id's will simply increment as they are generated.

virtual ~Timer   throw () [virtual]
 

Destroy this Timer object


Member Function Documentation

unsigned long addEvent unsigned    long,
bool    periodic = false
throw (Synchronization_Exception)
 

Set a timer. An event will occur after the given amount of time expires. This method will create a new TimerEvent with a unique id which will be submitted to the Timer's event list.

Parameters:
unsigned  long - milliseconds until event
bool  - event repeats
Returns:
unsigned long - event id
Exceptions:
Synchronization_Exception 

bool delEvent unsigned    long throw (Synchronization_Exception)
 

Delete a TimerEvent. If an event exists in this Timer's event list (the event has not expired) with the given id then it will be removed from that list.

Parameters:
unsigned  lone - event id
Returns:
bool - true if the event is successfulyl removed, false if not.
Exceptions:
Synchronization_Exception 

unsigned long now   throw () [static]
 

Get the curent time in milliseconds relative to the time the library was loaded.

Returns:
unsigned long

virtual void run   throw () [virtual]
 

This method enters a loop, waiting on the condition variable that is associated with this object. This loop will executed until the Timer has been canceled.

Implements Runnable.

Reimplemented in TimerThread.


The documentation for this class was generated from the following file:
Generated on Fri May 31 14:08:47 2002 for ZThread by doxygen1.2.15