public abstract class Timer extends AsyncEvent implements Timable
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 |
---|---|
void |
bindTo(String happening)
Should not be called, since this was only meant for binding happenings to normal instances AsyncEvent, not to special subclasses.
|
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.
|
TimeDispatcher |
getDispatcher()
Gets the dispatcher associated with this Timable.
|
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, handledBy, handledBy, removeHandler, removeHandler, setHandler, setHandler, unbindTo
hasHandlers
protected Timer(HighResolutionTime<?> time, Clock clock, 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().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 TimeDispatcher getDispatcher()
getDispatcher
in interface Releasable<Timable,TimeDispatcher>
getDispatcher
in interface Timable
UnsupportedOperationException
- always, since it is not yet
implemented.public boolean isRunning()
isRunning
in class AsyncBaseEvent
public void start()
public void start(boolean disabled)
StaticIllegalStateException
- if this timer is destroyed.disabled
- true to make this timer active but disabled.public boolean stop()
StaticIllegalStateException
- 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
StaticIllegalStateException
- 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().
enable
in class AsyncBaseEvent
StaticIllegalStateException
- 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.
disable
in class AsyncBaseEvent
StaticIllegalStateException
- if this timer has been destroyed.public void destroy()
StaticIllegalStateException
- if this timer has been destroyed.public void fire() throws UnsupportedOperationException
fire
in class AsyncEvent
UnsupportedOperationException
- always thrown.public Clock getClock()
StaticIllegalStateException
- if this timer has been destroyed.public AbsoluteTime getFireTime()
StaticIllegalStateException
- if this timer has been destroyed or
it is not active.public AbsoluteTime getFireTime(AbsoluteTime dest)
StaticIllegalStateException
- 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)
StaticIllegalStateException
- if this timer has been destroyed.time
- the new time parameter.public void bindTo(String happening) throws UnsupportedOperationException
bindTo
in class AsyncEvent
UnsupportedOperationException
- everytime, since this operation is not supported.happening
- to which to bind.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.