|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object seda.sandStorm.core.ssTimer
public class ssTimer
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!
WARNING: delivery is NOT guaranteed given the use of enqueue_lossy().
Nested Class Summary | |
---|---|
private static class |
ssTimer.GQEString
|
static class |
ssTimer.ssTimerEvent
|
Field Summary | |
---|---|
private static int |
DEBUG_LEVEL
|
private boolean |
die_thread
|
private ssTimer.ssTimerEvent |
head_event
|
private int |
num_events
|
private java.lang.Object |
sync_o
|
private ssTimer.ssTimerEvent |
tail_event
|
private java.lang.Thread |
thr
|
Constructor Summary | |
---|---|
ssTimer()
|
Method Summary | |
---|---|
void |
cancelAll()
Cancel all events, removing them from the queue. |
void |
cancelEvent(ssTimer.ssTimerEvent evt)
Cancels the firing of this timer event. |
private static boolean |
DEBUG(int n)
|
void |
doneWithTimer()
Kills off this timer object, dropping all pending events on floor. |
private void |
insertEvent(ssTimer.ssTimerEvent newTimer)
|
static void |
main(java.lang.String[] args)
|
private void |
process_head()
called by run() with a lock on sync_o and an event in the queue |
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()
loop while die_thread==false, processing events as they are queued |
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 |
Field Detail |
---|
private static final int DEBUG_LEVEL
private ssTimer.ssTimerEvent head_event
private ssTimer.ssTimerEvent tail_event
private java.lang.Thread thr
private java.lang.Object sync_o
private boolean die_thread
private int num_events
Constructor Detail |
---|
public ssTimer()
Method Detail |
---|
private static final boolean DEBUG(int n)
public ssTimer.ssTimerEvent registerEvent(long millis, QueueElementIF obj, SinkIF queue)
obj
will be placed on SinkIF queue
no earlier than millis
milliseconds from now.
millis
- the number of milliseconds from now when the event will
take placeobj
- the object that will be placed on the queuequeue
- the queue on which the object will be placedpublic ssTimer.ssTimerEvent registerEvent(java.util.Date the_date, QueueElementIF obj, SinkIF queue)
obj
will be placed on SinkIF queue
no earlier than absolute time the_date
.
the_date
- the date when the event will take place - if this date
is in the past, the event will happen right awayobj
- the object that will be placed on the queuequeue
- the queue on which the object will be placedpublic void doneWithTimer()
public int size()
public int profileSize()
profileSize
in interface ProfilableIF
public void cancelAll()
public void cancelEvent(ssTimer.ssTimerEvent evt)
evt
- the ssTimer.ssTimerEvent to cancel. This ssTimerEvent
is returned to you when you call registerEventprivate void insertEvent(ssTimer.ssTimerEvent newTimer)
private void process_head()
public void run()
run
in interface java.lang.Runnable
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |