public class PeriodicTimer extends Timer
This timer event fires periodically.
Constructor and Description |
---|
PeriodicTimer(HighResolutionTime<?> start,
RelativeTime interval,
AsyncBaseEventHandler handler)
Constructor to create an instance with given time, interval and
handler.
|
PeriodicTimer(HighResolutionTime<?> start,
RelativeTime interval,
AsyncEventHandler handler)
Constructor to create an instance with given time, interval and
handler.
|
PeriodicTimer(HighResolutionTime<?> start,
RelativeTime interval,
AsyncEventHandler handler,
TimeDispatcher dispatcher)
Creates a timer that executes its fire method periodically.
|
PeriodicTimer(HighResolutionTime<?> start,
RelativeTime interval,
Clock clock,
AsyncBaseEventHandler handler)
Constructor to create an instance with given time, interval,
clock and handler.
|
PeriodicTimer(HighResolutionTime<?> start,
RelativeTime interval,
Clock clock,
AsyncEventHandler handler)
Constructor to create an instance with given time, interval,
clock and handler.
|
Modifier and Type | Method and Description |
---|---|
ReleaseParameters<?> |
createReleaseParameters()
createReleaseParameters creates the default release
parameters for this event.
|
AbsoluteTime |
getFireTime()
getFireTime returns the time at which this timer is expected to
fire or skip firing (because it is disabled) next.
|
RelativeTime |
getInterval()
getInterval returns the interval of this periodic timer.
|
PeriodicTimer |
setInterval(RelativeTime newinterval)
setInterval changes the interval for this periodic timer.
|
bindTo, destroy, finalize, fire, getClock, getDispatcher, getEffectiveStartTime, getEffectiveStartTime, getFireTime, getStart, isActive, isRunning, reschedule, setDispatcher, setStartTime, 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 PeriodicTimer(HighResolutionTime<?> start, RelativeTime interval, AsyncBaseEventHandler handler)
StaticIllegalArgumentException
- if time or interval is a
negative RelativeTime.start
- The time when this timer should fire first. 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().interval
- The interval or null to get a behavior like
OneShotTimer.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 PeriodicTimer(HighResolutionTime<?> start, RelativeTime interval, AsyncEventHandler handler)
This method has been replaced in RTSJ 2.0 to support the more generic AsyncBaseEventHandler and is kept for binary compatibility.
public PeriodicTimer(HighResolutionTime<?> start, RelativeTime interval, Clock clock, AsyncBaseEventHandler handler)
StaticIllegalArgumentException
- if time or interval is a
negative RelativeTime.start
- The time when this timer should fire first. 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().interval
- The interval or null to get a behavior like
OneShotTimer.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 PeriodicTimer(HighResolutionTime<?> start, RelativeTime interval, Clock clock, AsyncEventHandler handler)
This method has been replaced in RTSJ 2.0 to support the more generic AsyncBaseEventHandler and is kept for binary compatibility.
public PeriodicTimer(HighResolutionTime<?> start, RelativeTime interval, AsyncEventHandler handler, TimeDispatcher dispatcher) throws StaticIllegalArgumentException, IllegalAssignmentError, StaticUnsupportedOperationException
StaticIllegalArgumentException
- when start
or
interval
is a RelativeTime
instance with a value less than zero; or the clocks associated with
start
and
interval
are not the identical.IllegalAssignmentError
- when this PeriodicTimer
cannot hold references to handler
,
clock
and interval
.StaticUnsupportedOperationException
- when the Chronograph
associated with time
is not a Clock
.start
- The time that specifies when the first interval
begins, based on the clock associated with it. The first
firing of the timer is modified according to the
PhasingPolicy
when the timer is started. A
start
value of null
is equivalent
to a RelativeTime
of 0.
interval
- The period of the timer. Its usage is based on the
clock specified by the clock
parameter. When
interval
is zero or null
, the
period is ignored and the firing behavior of the
PeriodicTimer
is that of a OneShotTimer
.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 to use for triggering this event.public ReleaseParameters<?> createReleaseParameters()
createReleaseParameters
in class Timer
StaticIllegalStateException
- if this timer is destroyed.public AbsoluteTime getFireTime()
getFireTime
in class Timer
StaticIllegalStateException
- if this timer has been destroyed.public RelativeTime getInterval()
StaticIllegalStateException
- if this timer has been destroyed.public PeriodicTimer setInterval(RelativeTime newinterval)
StaticIllegalArgumentException
- if time or interval is a
negative RelativeTime.newinterval
- the new interval.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2024 aicas GmbH. All Rights Reserved.