java.lang.Object javax.realtime.AsyncEvent javax.realtime.Timer javax.realtime.OneShotTimer
A timed AsyncEvent
that is driven by a Clock
.
It will fire off once,
when the clock time reaches the time-out time, unless restarted after
expiration.
If the timer is disabled at the expiration of the indicated time,
the firing is lost (skipped).
After expiration, the OneShotTimer
becomes
not-active and disabled.
If the clock time has
already passed the time-out time, it will fire immediately after it is
started or after it is rescheduled while active.
Semantics details are described in the Timer
pseudocode
and compact graphic representation of state transitions.
Caution: This class is explicitly unsafe in multithreaded situations when it is being changed. No synchronization is done. It is assumed that users of this class who are mutating instances will be doing their own synchronization at a higher level.
Constructor Summary | |
OneShotTimer(HighResolutionTime time,
AsyncEventHandler handler)
Create an instance of OneShotTimer , based on the Clock
associated with the time parameter, that will execute its
fire method according to the given time. |
|
OneShotTimer(HighResolutionTime time,
Clock clock,
AsyncEventHandler handler)
Create an instance of OneShotTimer , based on the given
clock , that will execute its
fire method according to the given time.
|
Methods inherited from class javax.realtime.Timer |
addHandler, bindTo, createReleaseParameters, destroy, disable, enable, fire, getClock, getFireTime, getFireTime, handledBy, isRunning, removeHandler, reschedule, setHandler, start, start, stop |
Methods inherited from class javax.realtime.AsyncEvent |
unbindTo |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public OneShotTimer(HighResolutionTime time, AsyncEventHandler handler)
OneShotTimer
, based on the Clock
associated with the time
parameter, that will execute its
fire
method according to the given time.
time
- The time used to determine when to fire the event.
A time
value of null
is equivalent to a
RelativeTime
of 0, and in this case
the Timer
fires
immediately upon a call to start()
.handler
- The AsyncEventHandler
that will be
released when fire
is invoked.
If null
, no handler is associated with this
Timer
and nothing will happen when this event fires
unless a handler is subsequently associated with the timer using the
addHandler()
or setHandler()
method.
java.lang.IllegalArgumentException
- Thrown if time
is a RelativeTime
instance less than zero.
java.lang.UnsupportedOperationException
- Thrown if the
timer functionality cannot be supported using
the clock
associated with time
.public OneShotTimer(HighResolutionTime time, Clock clock, AsyncEventHandler handler)
OneShotTimer
, based on the given
clock
, that will execute its
fire
method according to the given time.
The Clock
association of the parameter time
is ignored.
time
- The time used to determine when to fire the event.
A time
value of null
is equivalent to a
RelativeTime
of 0, and in this case
the Timer
fires
immediately upon a call to start()
.clock
- The clock on which to base this timer, overriding
the clock associated with the parameter time
.
If null
, the system Realtime clock
is used.
The clock associated with the parameter time
is always
ignored.handler
- The AsyncEventHandler
that will be
released when fire
is invoked.
If null
, no handler is associated with this
Timer
and nothing will happen when this event fires
unless a handler is subsequently associated with the timer using the
addHandler()
or setHandler()
method.
java.lang.IllegalArgumentException
- Thrown if time
is a RelativeTime
instance less than zero.
java.lang.UnsupportedOperationException
- Thrown if the
timer functionality cannot be supported using
the given clock
.