    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.

##

EventManager()

##

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

##

EventManager

     public EventManager()

##

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.

stopEventManager

     public synchronized void stopEventManager()

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.

recallTimer

     public synchronized Object recallTimer(Object timer)

  This recalls a previously registered timer event.

run

     public void run()

  Overrides:
    run in class Thread

handleTimerEvent

     public void handleTimerEvent(Object rock,
                                  long time)

main

     public static void main(String args[])

    All Packages  Class Hierarchy  This Package  Previous  Next  Index