public class OneShotTimer extends Timer
This event will fire once at a specified time.
Constructor and Description |
---|
OneShotTimer(HighResolutionTime<?> time,
AsyncBaseEventHandler handler)
Constructor to create an instance with given time and handler.
|
OneShotTimer(HighResolutionTime<?> time,
AsyncBaseEventHandler handler,
TimeDispatcher dispatcher)
Creates an instance of
OneShotTimer , based on the given
clock , that will execute its fire method
according to the given time. |
OneShotTimer(HighResolutionTime<?> time,
AsyncEventHandler handler)
Deprecated.
since RTSJ 2.0
|
OneShotTimer(HighResolutionTime<?> start,
Clock clock,
AsyncEventHandler handler)
Deprecated.
since RTSJ 2.0
|
bindTo, createReleaseParameters, destroy, finalize, fire, getClock, getDispatcher, getEffectiveStartTime, getEffectiveStartTime, getFireTime, getFireTime, getStart, isActive, isRunning, reschedule, setDispatcher, start, start, start, start, stop
addHandler, handledBy, removeHandler, setHandler, unbindTo
addHandler, disable, enable, handledBy, hasHandlers, removeHandler, setHandler
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disable, enable
public OneShotTimer(HighResolutionTime<?> time, AsyncBaseEventHandler handler)
StaticIllegalArgumentException
- if time is a negative
RelativeTime.time
- The time when this timer should fire. May be null, in
this case this is equal to new RelativeTime(0, 0) and the firing
will occur immediately after a call to start().handler
- The handler that will be released when this timer
fires. May be null to have no handler until one will be added via
addHandler.@Deprecated public OneShotTimer(HighResolutionTime<?> time, AsyncEventHandler handler)
This method has been replaced in RTSJ 2.0 to support the more generic AsyncBaseEventHandler and is kept for binary compatibility.
@Deprecated public OneShotTimer(HighResolutionTime<?> start, Clock clock, AsyncEventHandler handler)
StaticIllegalArgumentException
- if time is a negative
RelativeTime.start
- The time when this timer should fire. May be null, in
this case this is equal to new RelativeTime(0, 0) and the firing
will occur immediately after a call to start().clock
- the clock this timer should be based upon. May be
null to use the default System.getRealtimeClock().handler
- The handler that will be released when this timer
fires. May be null to have no handler until one will be added via
addHandler.public OneShotTimer(HighResolutionTime<?> time, AsyncBaseEventHandler handler, TimeDispatcher dispatcher) throws StaticIllegalArgumentException, StaticUnsupportedOperationException, IllegalAssignmentError
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.StaticIllegalArgumentException
- when time
is a
RelativeTime
instance less than zero.StaticUnsupportedOperationException
- when the Chronograph
associated with time
is not a Clock
.IllegalAssignmentError
- when this OneShotTimer
cannot hold references to time
, handler
,
or clock
.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 default handler
to use for this event.
When null
, no handler
is associated with the
timer and nothing will happen when this event fires unless a
handler
is subsequently associated with the timer
using the addHandler()
or setHandler()
method.dispatcher
- The dispatcher
used to interface between
this timer
and its associated clock. When
null
, the system default dispatcher is used.