01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.core.agent.service.alarm;
28:
29: /**
30: * Interface for an object telling the AlarmService to wake a client
31: * in the future.
32: *
33: * @see org.cougaar.core.service.AlarmService
34: */
35: public interface Alarm {
36: /**
37: * @return absolute time (in milliseconds) that the Alarm should
38: * go off. This value must be implemented as a fixed value.
39: */
40: long getExpirationTime();
41:
42: /**
43: * Called by the agent's alarm time when clock-time >= getExpirationTime().
44: * <p>
45: * The system will attempt to Expire the Alarm as soon as possible on
46: * or after the ExpirationTime, but cannot guarantee any specific
47: * maximum latency.
48: * NOTE: this will be called in the thread of the cluster clock.
49: * Implementations should make certain that this code does not block
50: * for a significant length of time.
51: * If the alarm has been canceled, this should be a no-op.
52: */
53: void expire();
54:
55: /**
56: * @return true IFF the alarm has rung (expired) or was canceled.
57: */
58: boolean hasExpired();
59:
60: /**
61: * This method can be called by a client to cancel the alarm.
62: * May or may not remove the alarm from the queue, but should
63: * prevent expire from doing anything.
64: * @return false IF the the alarm has already expired or was already canceled.
65: */
66: boolean cancel();
67: }
|