javax.realtime
Class PeriodicTimer

java.lang.Object
  |
  +--javax.realtime.AsyncEvent
        |
        +--javax.realtime.Timer
              |
              +--javax.realtime.PeriodicTimer

public class PeriodicTimer
extends Timer

An AsyncEvent whose fire method is executed periodically according to the given parameters. If a clock is given, calculation of the period uses the increments of the clock. If an interval is given or set the system guarantees that the fire method will execute interval time units after the last execution or its given start time as appropriate. If one of the HighResolutionTime argument types is RationalTime then the system guarantees that the fire method will be executed exactly frequency times every unit time (see RationalTime constructors) by adjusting the interval between executions of fire(). This is similar to a thread with PeriodicParameters except that it is lighter weight. If a PeriodicTimer is disabled, it still counts, and if enabled at some later time, it will fire at its next scheduled fire time.


Fields inherited from class javax.realtime.Timer
clock, isEnabled, started, time, timerThread, waitLock
 
Constructor Summary
PeriodicTimer(HighResolutionTime start, RelativeTime interval, AsyncEventHandler handler)
          Create an instance of AsyncEvent that executes its fire method periodiacally
PeriodicTimer(HighResolutionTime start, RelativeTime interval, Clock clock, AsyncEventHandler handler)
          Create an instance of AsyncEvent that executes its fire method periodiacally
 
Method Summary
 ReleaseParameters createReleaseParameters()
          Create a ReleaseParameters object with the next fire time as the start time and the interval of this as the period.
 void fire()
          Fire (schedule the run() methods of) the handlers associated with this event.
 AbsoluteTime getFireTime()
          Get the time at which this event will fire
 RelativeTime getInterval()
          Return the interval of this Timer
protected  void Init()
           
 void setInterval(RelativeTime interval)
          Reset the interval of this Timer
 
Methods inherited from class javax.realtime.Timer
destroy, disable, enable, getClock, reschedule, start
 
Methods inherited from class javax.realtime.AsyncEvent
addHandler, bindTo, handledBy, removeHandler, setHandler, unbindTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeriodicTimer

public PeriodicTimer(HighResolutionTime start,
                     RelativeTime interval,
                     AsyncEventHandler handler)
Create an instance of AsyncEvent that executes its fire method periodiacally
Parameters:
start - The time when the first interval begins
interval - The time between successive executions of the fire method
handler - The instance of AsyncEventHandler that will be scheduled each time the fire method is exceuted

PeriodicTimer

public PeriodicTimer(HighResolutionTime start,
                     RelativeTime interval,
                     Clock clock,
                     AsyncEventHandler handler)
Create an instance of AsyncEvent that executes its fire method periodiacally
Parameters:
start - The time when the first interval begins
interval - The time between successive executions of the fire method
clock - The clock whose increments are used to calculate the interval
handler - The instance of AsyncEventHandler that will be scheduled each time the fire method is exceuted
Method Detail

createReleaseParameters

public ReleaseParameters createReleaseParameters()
Create a ReleaseParameters object with the next fire time as the start time and the interval of this as the period.
Overrides:
createReleaseParameters in class Timer
Returns:
an instance of ReleaseParameters object

fire

public void fire()
Description copied from class: AsyncEvent
Fire (schedule the run() methods of) the handlers associated with this event.
Overrides:
fire in class AsyncEvent

getFireTime

public AbsoluteTime getFireTime()
Description copied from class: Timer
Get the time at which this event will fire
Overrides:
getFireTime in class Timer
Tags copied from class: Timer
Returns:
an AbsoluteTime object representing the absolute time at which this will fire.

getInterval

public RelativeTime getInterval()
Return the interval of this Timer
Returns:
a RelativeTime object which is the current interval of this

setInterval

public void setInterval(RelativeTime interval)
Reset the interval of this Timer
Parameters:
interval - A RelativeTime object which is the interval to reset this Timer

Init

protected void Init()
Overrides:
Init in class Timer