com.caucho.util
Class AlarmHeap

java.lang.Object
  extended by com.caucho.util.AlarmHeap

public class AlarmHeap
extends java.lang.Object

The alarm class provides a lightweight event scheduler. This allows an objects to schedule a timeout without creating a new thread.

A separate thread periodically tests the queue for alarms ready.


Constructor Summary
AlarmHeap()
          Create a new wakeup alarm with a designated listener as a callback.
 
Method Summary
 void dequeue(Alarm alarm)
           
 Alarm extractAlarm(long now)
          Returns the next alarm ready to run
 boolean queueAt(Alarm alarm, long wakeTime)
          Queue the alarm for wakeup.
 Alarm[] toArray()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlarmHeap

public AlarmHeap()
Create a new wakeup alarm with a designated listener as a callback. The alarm is not scheduled.

Method Detail

extractAlarm

public Alarm extractAlarm(long now)
Returns the next alarm ready to run


queueAt

public boolean queueAt(Alarm alarm,
                       long wakeTime)
Queue the alarm for wakeup.

Parameters:
delta - time in milliseconds to wake

dequeue

public void dequeue(Alarm alarm)

toArray

public Alarm[] toArray()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object