Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.caucho.util
Class Alarm

    java.lang.Object
      |
      +--com.caucho.util.Alarm

public class Alarm
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.

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

### Alarm

    public Alarm(AlarmListener listener)

  Create a new wakeup alarm with a designated listener as a callback. The alarm is not scheduled.

### Alarm

    public Alarm(java.lang.String name,
                 AlarmListener listener,
                 long delta)

  Creates a named alarm and schedules its wakeup.
  Parameters:
    `name` - the object prepared to receive the callback
    `listener` - the object prepared to receive the callback
    `delta` - the time in milliseconds to wake up

### Alarm

    public Alarm(AlarmListener listener,
                 long delta)

  Creates a new alarm and schedules its wakeup.
  Parameters:
    `listener` - the object prepared to receive the callback
    `delta` - the time in milliseconds to wake up

Method Detail

### getCurrentTime

    public static long getCurrentTime()

  Returns the current time. Convenient for minimizing system calls.

### getWakeTime

    public long getWakeTime()

  Returns the wake time of this alarm.

### getListener

    public AlarmListener getListener()

  Return the alarm's listener.

### setListener

    public void setListener(AlarmListener listener)

  Sets the alarm's listener.

### queue

    public void queue(long delta)

  Queue the alarm for wakeup.
  Parameters:
    `delta` - time in milliseconds to wake

### dequeue

    public void dequeue()

  Remove the alarm from the wakeup queue.

### toString

    public java.lang.String toString()

  Overrides:
    toString in class java.lang.Object

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD