javax.realtime
Class Timed
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--java.lang.InterruptedException
|
+--javax.realtime.AsynchronouslyInterruptedException
|
+--javax.realtime.Timed
- All Implemented Interfaces:
- java.io.Serializable
- public class Timed
- extends AsynchronouslyInterruptedException
Create a scope in a RealtimeThread for which interrupt() will be called 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().
All memory use of Timed occurs during construction or the first invocation
of doInterruptible(). Subsequent invokes of doInterruptible() do not
allocate memory.
Usage: new Timed(T).doInterruptible(interruptible);
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace, printStackTrace, printStackTrace, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Timed
public Timed(HighResolutionTime time)
throws java.lang.IllegalArgumentException
- Create an instance of
Timed with a timer set to timeout. If the time is in the past the
AsynchronouslyInterruptedException mechanism is immediately activated.
- Parameters:
time - The interval of time between the invocation of
doInterruptible() and when interrupt() is
called on currentRealtimeThread(). If null the IllegalArgumentException is thrown.
doInterruptible
public boolean doInterruptible(Interruptible logic)
- Execute a timeout method.
Starts the timer and executes the
run() method of the
given Interruptible object.
- Overrides:
doInterruptible in class AsynchronouslyInterruptedException
- Parameters:
logic - Implements an Interruptible run() method. If null nothing happens.
resetTime
public void resetTime(HighResolutionTime time)
- To reschedule the timeout for the next invocation of
doInterruptible().
- Parameters:
time - This can be an absolute time or a relative time. If null the
timeout is not changed.