More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.sandStorm.core
Class ssTimer

java.lang.Object
  |
  +--seda.sandStorm.core.ssTimer
All Implemented Interfaces:
ProfilableIF, java.lang.Runnable

public class ssTimer
extends java.lang.Object
implements java.lang.Runnable, ProfilableIF

The ssTimer class provides a mechanism for registering timer events that will go off at some future time. The future time can be specified in absolute or relative terms. When the timer goes off, an element is placed on a queue. There is no way to unregister a timer. Events will be delivered guaranteed, but the time that they are delivered may slip depending on stuff like how loaded the system is and all that.

WARNING: you should use cancelEvent to cancel timers that you no longer need, otherwise you will waste many, many cycles on unneeded timer firings. This was the bottleneck in vSpace and the DDS before we fixed it. For example, if you set a timer to go off on a cross-CPU task to detect failure, then if the task returns successfully, cancel the timer!

Author:
Matt Welsh and Steve Gribble

Inner Class Summary
static class ssTimer.ssTimerEvent
           
 
Constructor Summary
ssTimer()
           
 
Method Summary
 void cancelAll()
          Cancels all events.
 void cancelEvent(ssTimer.ssTimerEvent evt)
          Cancels the firing of this timer event.
 void doneWithTimer()
          Kills off this timer object, dropping all pending events on floor.
static void main(java.lang.String[] args)
           
 int profileSize()
          Return the profile size of this timer.
 ssTimer.ssTimerEvent registerEvent(java.util.Date the_date, QueueElementIF obj, SinkIF queue)
          Object obj will be placed on SinkIF queue no earlier than absolute time the_date.
 ssTimer.ssTimerEvent registerEvent(long millis, QueueElementIF obj, SinkIF queue)
          Object obj will be placed on SinkIF queue no earlier than millis milliseconds from now.
 void run()
           
 int size()
          How many events yet to fire?
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ssTimer

public ssTimer()
Method Detail

registerEvent

public ssTimer.ssTimerEvent registerEvent(long millis,
                                          QueueElementIF obj,
                                          SinkIF queue)
Object obj will be placed on SinkIF queue no earlier than millis milliseconds from now.
Parameters:
millis - the number of milliseconds from now when the event will take place
obj - the object that will be placed on the queue
queue - the queue on which the object will be placed

registerEvent

public ssTimer.ssTimerEvent registerEvent(java.util.Date the_date,
                                          QueueElementIF obj,
                                          SinkIF queue)
Object obj will be placed on SinkIF queue no earlier than absolute time the_date.
Parameters:
the_date - the date when the event will take place - if this date is in the past, the event will happen right away
obj - the object that will be placed on the queue
queue - the queue on which the object will be placed

doneWithTimer

public void doneWithTimer()
Kills off this timer object, dropping all pending events on floor.

size

public int size()
How many events yet to fire?

profileSize

public int profileSize()
Return the profile size of this timer.
Specified by:
profileSize in interface ProfilableIF

cancelAll

public void cancelAll()
Cancels all events.

cancelEvent

public void cancelEvent(ssTimer.ssTimerEvent evt)
Cancels the firing of this timer event.
Parameters:
evt - the ssTimer.ssTimerEvent to cancel. This ssTimerEvent is returned to you when you call registerEvent

run

public void run()
Specified by:
run in interface java.lang.Runnable

main

public static void main(java.lang.String[] args)

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/