01: package org.directwebremoting.extend;
02:
03: /**
04: * An alarm is something that goes off at some point in the future.
05: * An alarm is not primed until {@link #setAlarmAction(Sleeper)} is called.
06: * {@link #setAlarmAction(Sleeper)} should only be called once before
07: * {@link #cancel()} is called, and the latter should only be called once.
08: * The alarm should not 'go off' after {@link #cancel()} has been called,
09: * however since this is a multi-threaded environment, {@link Sleeper}s
10: * should protect themselves from late calls to {@link Sleeper#wakeUp()}.
11: * @author Joe Walker [joe at getahead dot ltd dot uk]
12: */
13: public interface Alarm {
14: /**
15: * Alarms need something to do when they go off.
16: * After this method has been called the Alarm may 'go off', once only,
17: * by calling {@link Sleeper#wakeUp()}.
18: * @param sleeper The action to awake when the alarm goes off
19: */
20: void setAlarmAction(Sleeper sleeper);
21:
22: /**
23: * Prevent further calls to {@link Sleeper#wakeUp()}.
24: * See the note about late calls above.
25: */
26: void cancel();
27: }
|