inria.util
Class EventManager

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--inria.util.EventManager
All Implemented Interfaces:
EventHandler, java.lang.Runnable

public class EventManager
extends java.lang.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.


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
EventManager()
          Undocumented Class Constructor.
 
Method Summary
 void handleTimerEvent(java.lang.Object rock, long time)
          Undocumented Method Declaration.
static void main(java.lang.String[] args)
          Undocumented Method Declaration.
 java.lang.Object recallTimer(java.lang.Object timer)
          This recalls a previously registered timer event.
 java.lang.Object registerTimer(inria.util.Event newEvent)
          This is like the above registerTimer, except it takes an event object with the deliver time filled in.
 java.lang.Object registerTimer(long ms, EventHandler handler, java.lang.Object data)
          registerTimer inserts a new timer event into the queue.
 void run()
          Undocumented Method Declaration.
static EventManager shared()
          Undocumented Method Declaration.
 void stopEventManager()
          Undocumented Method Declaration.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventManager

public EventManager()
Undocumented Class Constructor.
See Also:
Method Detail

shared

public static EventManager shared()
Undocumented Method Declaration.
Returns:
 
See Also:

registerTimer

public java.lang.Object registerTimer(long ms,
                                      EventHandler handler,
                                      java.lang.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 void stopEventManager()
Undocumented Method Declaration.
See Also:

registerTimer

public java.lang.Object registerTimer(inria.util.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 java.lang.Object recallTimer(java.lang.Object timer)
This recalls a previously registered timer event.

run

public void run()
Undocumented Method Declaration.
Overrides:
run in class java.lang.Thread
See Also:

handleTimerEvent

public void handleTimerEvent(java.lang.Object rock,
                             long time)
Undocumented Method Declaration.
Specified by:
handleTimerEvent in interface EventHandler
Parameters:
rock -  
time -  
See Also:

main

public static void main(java.lang.String[] args)
Undocumented Method Declaration.
Parameters:
args -  
See Also:


JavaTM Reliable MulticastTM Service version 1.1
Copyright (c) 2001, Sun Microsystems Laboratories, All rights reserved.