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
Field Summary |
(package private) javax.realtime.HighResolutionTime |
timeout
|
Fields inherited from class java.lang.Exception |
|
Fields inherited from class java.lang.Throwable |
|
Constructor Summary |
Timed(javax.realtime.HighResolutionTime time)
Create an instance of Timed with a timer set
to timeout. |
Method Summary |
boolean |
doInterruptible(javax.realtime.Interruptible logic)
Execute a timeout method. |
void |
resetTime(javax.realtime.HighResolutionTime time)
To reschedule the timeout for the next invocation of
doInterruptible() . |
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 |
timeout
javax.realtime.HighResolutionTime timeout
Timed
public Timed(javax.realtime.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
java.lang.IllegalArgumentException
is thrown.
- Throws:
java.lang.IllegalArgumentException
doInterruptible
public boolean doInterruptible(javax.realtime.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.
- Returns:
- True if the method call completed normally. False if another call to
doInterruptible()
has not completed.
resetTime
public void resetTime(javax.realtime.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.