com.tivoli.twg.engine
Class TWGQueueTimer

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGQueueTimer
All Implemented Interfaces:
java.lang.Runnable

public class TWGQueueTimer
extends java.lang.Object
implements java.lang.Runnable

TWGTimerQueue is a class that allows sub-classed objects to be enqueued based on the time of day. Items on the queue will be "run" when the server time of day has passed the time of day marked in the enqueued element. The sub-class must implement a "process" method.


Field Summary
protected  java.lang.Thread myThread
           
 
Method Summary
static void enqueue(TWGQueueElement element, java.util.Date tod)
          This method adds a TWGQueueElement to TWGQueueTimer's queue.
static void enqueue(TWGQueueElement element, long tod, boolean realTime)
          This method adds a TWGQueueElement to TWGQueueTimer's queue.
static boolean remove(TWGQueueElement element)
          This method removes a TWGQueueElement from the TWGQueueTimer's queue.
 void run()
          Our thread's entry point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myThread

protected java.lang.Thread myThread
Method Detail

enqueue

public static void enqueue(TWGQueueElement element,
                           long tod,
                           boolean realTime)
This method adds a TWGQueueElement to TWGQueueTimer's queue. The new element is placed in the queue sorted by wake up time/date.

Parameters:
element - TWGQueueElement object to be added to the queue.
tod - The time/date of day when the element's "process" method is to be called.
realTime - TRUE : specified time is actual time/date in mSec the element is to be processed. FALSE: the specified time is the number of mSec from the current time the element is to be processed.

enqueue

public static void enqueue(TWGQueueElement element,
                           java.util.Date tod)
This method adds a TWGQueueElement to TWGQueueTimer's queue. The new element is placed in the queue sorted by wake up time/date.

Parameters:
element - TWGQueueElement object to be added to the queue.
tod - Date object representing absolute time/date the element is to be popped.

run

public void run()
Our thread's entry point. This method will remove enqueued elements as long as elements are found to be time expired. As elements are removed, their "wakeUp" methods are called. This thread sleeps as soon as an element is reached that does not have an expired time. If the queue becomes empty, the thread sleeps indefinately until an element is enqueued.

Specified by:
run in interface java.lang.Runnable

remove

public static boolean remove(TWGQueueElement element)
This method removes a TWGQueueElement from the TWGQueueTimer's queue. If the object has been enqueued more than once, the object closest to the head of the queue will be removed.

Parameters:
element - TWGQueueElement object to be removed.
Returns:
TRUE: element was found and removed. FALSE: element was not found in list.