public abstract class Timer extends AsyncEvent implements AsyncTimable, ActiveEvent<Timable,TimeDispatcher>
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(java.lang.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().
|
protected void |
finalize() |
void |
fire()
fires this event unless firing is disabled and reschedules
the timer in case it is periodic.
|
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 |
isActive()
Determines the activation state of this event, i.e., it has been started
but not yet stopped again.
|
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, handledBy, removeHandler, setHandler, unbindTo
addHandler, handledBy, hasHandlers, removeHandler, setHandler
protected Timer(HighResolutionTime<?> time, Clock clock, AsyncBaseEventHandler handler)
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.StaticIllegalArgumentException
- if time is a negative
RelativeTime.public TimeDispatcher getDispatcher()
getDispatcher
in interface Releasable<Timable,TimeDispatcher>
getDispatcher
in interface Timable
java.lang.UnsupportedOperationException
- always, since it is not yet
implemented.public boolean isRunning()
isRunning
in interface ActiveEvent<Timable,TimeDispatcher>
isRunning
in class AsyncBaseEvent
public boolean isActive()
ActiveEvent
isActive
in interface ActiveEvent<Timable,TimeDispatcher>
true
when active, false
otherwise.public void start()
start
in interface ActiveEvent<Timable,TimeDispatcher>
public void start(boolean disabled)
start
in interface ActiveEvent<Timable,TimeDispatcher>
disabled
- true to make this timer active but disabled.StaticIllegalStateException
- if this timer is destroyed.public boolean stop()
stop
in interface ActiveEvent<Timable,TimeDispatcher>
StaticIllegalStateException
- if this timer is destroyed.public ReleaseParameters<?> createReleaseParameters()
createReleaseParameters
in class AsyncEvent
StaticIllegalStateException
- if this timer is destroyed.public void enable()
enable
in interface ActiveEvent<Timable,TimeDispatcher>
enable
in class AsyncBaseEvent
StaticIllegalStateException
- if this timer has been destroyed.public void disable()
disable
in interface ActiveEvent<Timable,TimeDispatcher>
disable
in class AsyncBaseEvent
StaticIllegalStateException
- if this timer has been destroyed.public void destroy()
StaticIllegalStateException
- if this timer has been destroyed.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)
dest
- the AbsoluteTime which will be updated and returned if
not null. If dest is null, a new instance of AbsoluteTime will be
returned.StaticIllegalStateException
- if this timer has been destroyed or
it is not active.public void reschedule(HighResolutionTime<?> time)
time
- the new time parameter.StaticIllegalStateException
- if this timer has been destroyed.public void fire()
fire
in interface AsyncTimable
fire
in class AsyncEvent
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void bindTo(java.lang.String happening) throws java.lang.UnsupportedOperationException
bindTo
in class AsyncEvent
happening
- to which to bind.java.lang.UnsupportedOperationException
- everytime, since this
operation is not supported.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2021 aicas GmbH. All Rights Reserved.