|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--one.world.core.Component
|
+--one.world.util.Timer
Implementation of a timer. A timer is a component that provides
event notification based on time. Notification can be once or
periodically, in which case it can be either fixed rate or fixed
delay, as described for java.util.Timer.
This component exports a request event handler that accepts
timer events requesting to schedule timed notification(s). This
event handler is forcibly linked through a concurrency domain to
ensure that timer notifications complete quickly. This component
also provides a synchronous interface through the schedule(int, long, long, one.world.core.EventHandler, one.world.core.Event)
method.
Unlike other resources in one.world, the timed notification provided by this component is not leased and, if it is periodic, must be explicitly canceled. As a result, this component can be used to implement leases.
If a timed notification results in an exceptional condition
other than a NoBufferSpaceException, any future
notification is automatically canceled. Furthermore, if the event
handler receiving timed notification is currently not active (as
determined by Domain.isActive(one.world.core.EventHandler)), the notification is
silently dropped.
Note that each environment has its own timer component, which
can be accessed through Component.getTimer().
Imported and Exported Event Handlers
Exported event handler(s):
| Inner Class Summary | |
static class |
Timer.Event
Definition of a timer event. |
static class |
Timer.Notification
The notification handler. |
| Inner classes inherited from class one.world.core.Component |
Component.HandlerReference, Component.Importer |
| Field Summary | |
static int |
CANCEL
The type code for canceling a timer. |
static int |
CANCELED
The type code for a canceled timer. |
static int |
FIXED_DELAY
The frequency code for a fixed delay timer. |
static int |
FIXED_RATE
The frequency code for a fixed rate timer. |
static int |
ONCE
The frequency code for a one-time timer. |
static int |
SCHEDULE
The type code for scheduling a timer. |
static int |
SCHEDULED
The type code for a scheduled timer. |
| Constructor Summary | |
Timer(Environment env)
Create a new instance of Timer. |
|
| Method Summary | |
ComponentDescriptor |
getDescriptor()
Get the component descriptor. |
Timer.Notification |
schedule(int frequency,
long firstTime,
long period,
EventHandler handler,
Event event)
Synchronously schedule timed notification(s). |
| Methods inherited from class one.world.core.Component |
declareExported, declareImported, equals, eventHandlers, getDescriptor, getEnvironment, getLinkedHandlers, getLinkedNumber, getTimer, hasEventHandler, hashCode, isFullyLinked, isLinked, isSealed, link, link, run, seal, unbox, undeclare, unlink, wrap |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int SCHEDULE
public static final int SCHEDULED
public static final int CANCEL
public static final int CANCELED
public static final int ONCE
public static final int FIXED_RATE
public static final int FIXED_DELAY
| Constructor Detail |
public Timer(Environment env)
Timer.env - The environment for the new instance.| Method Detail |
public ComponentDescriptor getDescriptor()
getDescriptor in class Componentone.world.core.Component
public Timer.Notification schedule(int frequency,
long firstTime,
long period,
EventHandler handler,
Event event)
frequency - The frequency.firstTime - The first time.period - The period.handler - The handler to receive notification(s).event - The event to signal notification(s).NullPointerException - Signals that handler or
event is null.IllegalArgumentException - Signals an invalid frequency, a negative first
time, or a non-positive period.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||