Class w3c.tools.timers.EventManager
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.tools.timers.EventManager

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----w3c.tools.timers.EventManager

public class EventManager
extends Thread
implements EventHandler
This implements an event manager for timer events. Timer events are a way to have events occur some time in the future. They are an alternative to using separate threads which issue sleep requests themselves.

Constructor Index

 o EventManager()

Method Index

 o handleTimerEvent(Object, long)
 o main(String[])
 o recallTimer(Object)
This recalls a previously registered timer event.
 o registerTimer(Event)
This is like the above registerTimer, except it takes an event object with the deliver time filled in.
 o registerTimer(long, EventHandler, Object)
registerTimer inserts a new timer event into the queue.
 o run()
 o stopEventManager()

Constructors

 o EventManager
  public EventManager()

Methods

 o registerTimer
  public Object registerTimer(long ms,
                              EventHandler handler,
                              Object data)
registerTimer inserts a new timer event into the queue. The queue is always sorted by time, in increasing order. That is, things farther into the future are further down in the queue. ms is milliseconds in the future, handler is the object that will handle the event, and data is a "rock" that is passed to the handler to do with what it will. This returns an opaque object which can be used to recall the timer before it is delivered.
 o stopEventManager
  public synchronized void stopEventManager()
 o registerTimer
  public synchronized Object registerTimer(Event newEvent)
This is like the above registerTimer, except it takes an event object with the deliver time filled in. If deliver time is before the current time, the event is "immediately" delivered. Do a binary search to figure out where the event goes.
 o recallTimer
  public synchronized Object recallTimer(Object timer)
This recalls a previously registered timer event.
 o run
  public void run()
Overrides:
run in class Thread
 o handleTimerEvent
  public void handleTimerEvent(Object rock,
                               long time)
 o main
  public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index