public abstract class Trigger extends Object implements Runnable
The Trigger class also supports the close() method where a Trigger can be set to ignore future trigger() calls once it is called. Use of this method is optional. If close() is called then eventually, the closed() method will also be called once all pending triggers are handled.
Constructor and Description |
---|
Trigger() |
Modifier and Type | Method and Description |
---|---|
void |
close()
This method will cause all future trigger() methods to return false
and the closed() method to be called in a separate Thread once all triggers have been handled.
|
protected void |
closed()
If the close() method is called then this method is called in a separate Thread.
|
protected void |
couldNotStartThread() |
protected abstract void |
doTriggerTask()
This gets called to handle one or multiple triggers.
|
void |
run()
This handles the correct invoking of doTriggerTask().
|
protected boolean |
startTriggerThread(Runnable t)
This may be overridden to handle running the trigger task in a separate thread.
|
boolean |
trigger()
"Pull" the trigger which will cause the doTriggerTask() to be called at least once in a separate Thread.
|
boolean |
waitUntilFullyClosed(long timeoutInMillis)
Wait until the Trigger has closed() called on it and until the closed() method has executed and returned.
|
protected boolean startTriggerThread(Runnable t)
t
- the Runnable that must be run() in the separate task.protected abstract void doTriggerTask()
protected void closed()
protected void couldNotStartThread()
public final boolean trigger()
public final void run()
public final void close()
public final boolean waitUntilFullyClosed(long timeoutInMillis) throws InterruptedException
timeoutInMillis
- - the length of time to wait before giving up. A value equal to zero means do not wait at all,
and a negative value indicates to wait indefinitely.InterruptedException