|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.caucho.util.Alarm
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.
You should use Cron for slow requests. Alarm is only appropriate for very short jobs.
Constructor Summary | |
Alarm(AlarmListener listener)
Create a new wakeup alarm with a designated listener as a callback. |
|
Alarm(AlarmListener listener,
long delta)
Creates a new alarm and schedules its wakeup. |
|
Alarm(java.lang.String name,
AlarmListener listener,
long delta)
Creates a named alarm and schedules its wakeup. |
Method Summary | |
void |
dequeue()
Remove the alarm from the wakeup queue. |
static long |
getCurrentTime()
Returns the current time. |
AlarmListener |
getListener()
Return the alarm's listener. |
long |
getWakeTime()
Returns the wake time of this alarm. |
void |
queue(long delta)
Queue the alarm for wakeup. |
void |
setListener(AlarmListener listener)
Sets the alarm's listener. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Alarm(AlarmListener listener)
public Alarm(java.lang.String name, AlarmListener listener, long delta)
name
- the object prepared to receive the callbacklistener
- the object prepared to receive the callbackdelta
- the time in milliseconds to wake uppublic Alarm(AlarmListener listener, long delta)
listener
- the object prepared to receive the callbackdelta
- the time in milliseconds to wake upMethod Detail |
public static long getCurrentTime()
public long getWakeTime()
public AlarmListener getListener()
public void setListener(AlarmListener listener)
public void queue(long delta)
delta
- time in milliseconds to wakepublic void dequeue()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |