javax.realtime
Class Timer
java.lang.Object
|
+--javax.realtime.AsyncEvent
|
+--javax.realtime.Timer
- Direct Known Subclasses:
- OneShotTimer, PeriodicTimer
- public abstract class Timer
- extends AsyncEvent
A Timer is a timed event that measures time relative to a given Clock. This
class defines basic functionality available to all timers. Applications will generally
use either PeriodicTimer to create an event that is fired repeatedly at regular
intervals, or OneShotTimer for an event that just fires once at a specific time. A
timer is always based on a Clock, which provides the basic facilities of something
that ticks along following some time line (real-time, cpu-time, user-time, simulation-time,
etc.). All timers are created disabled and do nothing until start() is called.
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
clock
protected Clock clock
time
protected HighResolutionTime time
isEnabled
protected boolean isEnabled
timerThread
protected RealtimeThread timerThread
waitLock
protected java.lang.Object waitLock
started
protected boolean started
Timer
protected Timer(HighResolutionTime t,
Clock c,
AsyncEventHandler handler)
- Create a timer that fires at time t, according to Clock c and is handled by the
specified handler
- Parameters:
t
- The time to fire the event, Will be converted to absolute time.c
- The clock on which to base this time. If null, the system realtime
clock is used.handler
- The default handler to use for this event. If null, no handler is
associated with it and nothing will happen when this event
fires until a handler is provided
createReleaseParameters
public ReleaseParameters createReleaseParameters()
- overrides: public ReleaseParameters createReleaseParameters() in class AsyncEvent
- Overrides:
- createReleaseParameters in class AsyncEvent
- Returns:
- an instance of ReleaseParameters
disable
public void disable()
- Disable this timer, preventing it from firing. It may subsequently be re-enabled.
If the timer is disabled when its fire time occurs then it will not fire.
However, a disabled timer continues to count while it is disabled and if it is
subsequently reabled before its fire time occures and is enabled when its fire time
occurs it will fire.
enable
public void enable()
- Re-enable this timer after it has been disabled.
destroy
public void destroy()
getClock
public Clock getClock()
- Return the Clock that this timer is based on
- Returns:
- clock The clock of this timer based on
getFireTime
public AbsoluteTime getFireTime()
- Get the time at which this event will fire
- Returns:
- an AbsoluteTime object representing the absolute time at which this will fire.
reschedule
public void reschedule(HighResolutionTime time)
- Change the scheduled time for this event. can take either absolute or relative times.
- Parameters:
t
- the time to reschedule for this event firing
if t is null, the previous fire time is still the time at which this will fire.
start
public void start()
- A Timer starts measuring time from when it is started
Init
protected abstract void Init()