org.objectweb.jonas_timer
Class TimerManager

java.lang.Object
  extended by org.objectweb.jonas_timer.TimerManager

public class TimerManager
extends java.lang.Object

A timer manager manages 2 lists of timers with 2 threads One thread is a clock which decrements timers every second and passes them when expired in a list of expired timers. The other thread looks in the list of expired timers to process them.


Method Summary
 TimerEvent addTimer(TimerEventListener tel, long timeout, java.lang.Object arg, boolean permanent)
          Deprecated. use addTimerMs instead.
 TimerEvent addTimerMs(TimerEventListener tel, long timeout, java.lang.Object arg, boolean permanent)
          add a new timer in the list
 void batch()
          process all expired timers
 void clock()
          update all timers in the list each timer expired is put in a special list of expired timers they will be processed then by the Batch Thread.
static TimerManager getInstance()
          Get an instance of the TimerManager
 void removeTimer(TimerEvent te)
          Deprecated.  
static void stop()
           
static void stop(boolean force)
          stop the service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TimerManager getInstance()
Get an instance of the TimerManager


stop

public static void stop(boolean force)
stop the service

Parameters:
force - tell the manager NOT to wait for the timers to be completed

stop

public static void stop()

clock

public void clock()
update all timers in the list each timer expired is put in a special list of expired timers they will be processed then by the Batch Thread.


batch

public void batch()
process all expired timers


addTimer

public TimerEvent addTimer(TimerEventListener tel,
                           long timeout,
                           java.lang.Object arg,
                           boolean permanent)
Deprecated. use addTimerMs instead.

add a new timer in the list

Parameters:
tel - Object that will be notified when the timer expire.
timeout - nb of seconds before the timer expires.
arg - info passed with the timer
permanent - true if the timer is permanent.

addTimerMs

public TimerEvent addTimerMs(TimerEventListener tel,
                             long timeout,
                             java.lang.Object arg,
                             boolean permanent)
add a new timer in the list

Parameters:
tel - Object that will be notified when the timer expire.
timeout - nb of milliseconds before the timer expires.
arg - info passed with the timer
permanent - true if the timer is permanent.

removeTimer

public void removeTimer(TimerEvent te)
Deprecated. 

remove a timer from the list. this is not very efficient. A better way to do this is TimerEvent.unset()