public abstract class ExecutionTimeBasedTimeout extends Object implements Timeout
super.init()
when overriding
init()
. They are also encouraged to check on the initialised
flag in
all methods.The class furthermore provides functionality to register and unregister
callbacks.Modifier and Type | Field and Description |
---|---|
protected Set<Runnable> |
callbacks
A set of callbacks which will be called once the timeout is reached.
|
protected boolean |
initialised
Indicates whether this object has been initialised.
|
protected long |
startingTime
The millisecond timestamp indicating when this Timeout object was initialised.
|
Constructor and Description |
---|
ExecutionTimeBasedTimeout() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
implementationInit()
For init methods of implementing classes.
|
void |
init()
Initialises the timeout object.
|
void |
registerCallback(Runnable callback)
Registers
callback to be run once the timeout is reached. |
void |
unregisterCallback(Runnable callback)
Removes
callback from the set of callbacks to be run once the timeout is
reached. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isReached, reportOneStepProgress
protected boolean initialised
protected long startingTime
public final void init()
Timeout
protected abstract void implementationInit()
init()
.public void registerCallback(Runnable callback)
Timeout
callback
to be run once the timeout is reached.registerCallback
in interface Timeout
callback
- A Runnable
object.public void unregisterCallback(Runnable callback)
Timeout
callback
from the set of callbacks to be run once the timeout is
reached.unregisterCallback
in interface Timeout
callback
- A Runnable
object.