public abstract class Timer extends AsyncEvent
Jamaica Real-Time Specification for Java class Timer.
abstract super class of PeriodicTimer or OneShotTimer. These timers are asynchronous events that fire at a given time.
Modifier | Constructor and Description |
---|---|
protected |
Timer(HighResolutionTime time,
Clock clock,
AsyncBaseEventHandler handler)
Constructor to create a timer with the given time, clock and
handler.
|
Modifier and Type | Method and Description |
---|---|
ReleaseParameters |
createReleaseParameters()
createReleaseParameters creates the default release parameters
for this event.
|
void |
destroy()
destroy destroys this timer, i.e., stops it from counting.
|
void |
disable()
disable disables firing of this timer.
|
void |
enable()
enable re-enables firing of this timer if it was disabled by a
previous call to disable().
|
void |
fire()
The fire method inherited from AsyncEvent must not be called, it
will throw an exception.
|
Clock |
getClock()
getClock returns the clock this timer was based on.
|
AbsoluteTime |
getFireTime()
getFireTime returns the time at which this timer is expected to
fire or skip firing (because it is disabled) next.
|
AbsoluteTime |
getFireTime(AbsoluteTime dest)
getFireTime returns the time at which this timer is expected to
fire or skip firing (because it is disabled) next.
|
boolean |
isRunning()
isRunning returns true if this timer has been started (it is
active) and it has not been disabled.
|
void |
reschedule(HighResolutionTime time)
reschedule changes the time for this event.
|
void |
start()
start this timer, i.e., make it active and enabled
|
void |
start(boolean disabled)
start this timer, i.e., make it active.
|
boolean |
stop()
stop stops this active timer changing its state to not-active and
disabled.
|
addHandler, addHandler, bindTo, handledBy, handledBy, removeHandler, removeHandler, setHandler, setHandler, unbindTo
protected Timer(HighResolutionTime time, Clock clock, AsyncBaseEventHandler handler)
IllegalArgumentException
- 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().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 boolean isRunning()
public void start()
public void start(boolean disabled)
IllegalStateException
- if this timer is destroyed.disabled
- true to make this timer active but disabled.public boolean stop()
IllegalStateException
- if this timer is destroyed.public ReleaseParameters createReleaseParameters()
createReleaseParameters creates the default release parameters for this event. The default implementation creates AperiodicParemters without cost/ deadline and without overrun or miss handler.
createReleaseParameters
in class AsyncEvent
IllegalStateException
- if this timer is destroyed.public void enable()
enable re-enables firing of this timer if it was disabled by a previous call to disable().
IllegalStateException
- if this timer has been destroyed.public void disable()
disable disables firing of this timer. The timer will continue execution like before, only it will not fire() when the given time is reached.
IllegalStateException
- if this timer has been destroyed.public void destroy()
IllegalStateException
- if this timer has been destroyed.public void fire() throws UnsupportedOperationException
fire
in class AsyncEvent
UnsupportedOperationException
- always thrown.public Clock getClock()
IllegalStateException
- if this timer has been destroyed.public AbsoluteTime getFireTime()
IllegalStateException
- if this timer has been destroyed or
it is not active.public AbsoluteTime getFireTime(AbsoluteTime dest)
IllegalStateException
- if this timer has been destroyed or
it is not active.dest
- the AbsoluteTime which will be updated and returned if
not null. If dest is null, a new instance of AbsoluteTime will be
returned.public void reschedule(HighResolutionTime time)
IllegalStateException
- if this timer has been destroyed.time
- the new time parameter.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2016 aicas GmbH. All Rights Reserved.