javax.realtime
Class PeriodicTimer

java.lang.Object
  extended byjavax.realtime.AsyncEvent
      extended byjavax.realtime.Timer
          extended byjavax.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.

Author:
Angelo Corsaro

Field Summary
 
Fields inherited from class javax.realtime.Timer
clock, isEnabled, isRunning
 
Fields inherited from class javax.realtime.AsyncEvent
handlerList, listIterator, releaseParams
 
Constructor Summary
PeriodicTimer(AbsoluteTime start, RelativeTime interval, AsyncEventHandler handler)
          Create an instance of AsyncEvent that executes its fire method periodiacally.
PeriodicTimer(AbsoluteTime start, RelativeTime interval, Clock clock, AsyncEventHandler handler)
          Creates a new PeriodicTimer instance.
PeriodicTimer(RelativeTime start, RelativeTime interval, AsyncEventHandler handler)
          Create an instance of AsyncEvent that executes its fire method periodiacally.
PeriodicTimer(RelativeTime start, RelativeTime interval, Clock clock, AsyncEventHandler handler)
          Creates a new PeriodicTimer instance.
 
Method Summary
 RelativeTime getInterval()
          Return the interval of this Timer.
protected  javax.realtime.TimerImpl getTimerImpl()
          This method is implemented in subclasses.
 void setInterval(RelativeTime interval)
          Set the interval for this periodic timer
 
Methods inherited from class javax.realtime.Timer
createReleaseParameters, destroy, disable, enable, getClock, getFireTime, isRunning, reschedule, start, stop
 
Methods inherited from class javax.realtime.AsyncEvent
addHandler, bindTo, fire, 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(RelativeTime 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 executed.

PeriodicTimer

public PeriodicTimer(RelativeTime start,
                     RelativeTime interval,
                     Clock clock,
                     AsyncEventHandler handler)
Creates a new PeriodicTimer instance.

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 executed.

PeriodicTimer

public PeriodicTimer(AbsoluteTime 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 executed.

PeriodicTimer

public PeriodicTimer(AbsoluteTime start,
                     RelativeTime interval,
                     Clock clock,
                     AsyncEventHandler handler)
Creates a new PeriodicTimer instance.

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 executed.
Method Detail

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)
Set the interval for this periodic timer

Parameters:
interval - a RelativeTime representing the new interval

getTimerImpl

protected javax.realtime.TimerImpl getTimerImpl()
Description copied from class: Timer
This method is implemented in subclasses.

Specified by:
getTimerImpl in class Timer


jRate is developed and maintained by the jRate project development team.
Copyright (c) 2001-2005 Angelo Corsaro and Morgan Deters.