Class Timed

  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.InterruptedException
              extended byjavax.realtime.AsynchronouslyInterruptedException
                  extended byjavax.realtime.Timed
All Implemented Interfaces:

public class Timed
extends AsynchronouslyInterruptedException

Create a scope in a Schedulable object which will be asynchronously interrupted at the expiration of a timer. This timer will begin measuring time at some point between the time doInterruptible() is invoked and the time the run() method of the Interruptible object is invoked. Each call of doInterruptible() on an instance of Timed will restart the timer for the amount of time given in the constructor or the most recent invocation of resetTime(). The timer is cancelled if it has not expired before the doInterruptible() method has finished.

All memory use of an instance of Timed occurs during construction or the first invocation of doInterruptible(). Subsequent invocations of doInterruptible() do not allocate memory.

If the timer fires, the resulting AIE will be generated for the schedulable object within a bounded execution time of the targeted schedulable object.

Typical usage: new Timed(T).doInterruptible(interruptible);

See Also:
Serialized Form

Constructor Summary
Timed(HighResolutionTime time)
          Create an instance of Timed with a timer set to time.
Method Summary
 boolean doInterruptible(Interruptible logic)
          Execute a time-out method.
 void resetTime(HighResolutionTime time)
          To set the time-out for the next invocation of doInterruptible().
Methods inherited from class javax.realtime.AsynchronouslyInterruptedException
clear, disable, enable, fire, getGeneric, happened, isEnabled, propagate
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public Timed(HighResolutionTime time)
Create an instance of Timed with a timer set to time. If the time is in the past the AsynchronouslyInterruptedException mechanism is activated immediately after or when the doInterruptible() method is called.

time - If time is a RelativeTime value, it is the interval of time between the invocation of doInterruptible() and when the schedulable object is asynchronously interrupted. If time is an AbsoluteTime value, the timer asynchronously interrupts at this time (assuming the timer has not been cancelled).
java.lang.IllegalArgumentException - Thrown if time is null.
Method Detail


public boolean doInterruptible(Interruptible logic)
Execute a time-out method. Starts the timer and executes the run() method of the given Interruptible object.

doInterruptible in class AsynchronouslyInterruptedException
logic - Implements an Interruptible run() method.
True if the method call completed normally. False if another call to doInterruptible has not completed.
java.lang.IllegalArgumentException - Thrown if logic is null.


public void resetTime(HighResolutionTime time)
To set the time-out for the next invocation of doInterruptible().

time - This can be an absolute time or a relative time. If null the time-out is not changed.