Package com.iizix
Class SingleRetriggerableTask
java.lang.Object
com.iizix.SingleRetriggerableTask
As single-runner task that is run by a trigger and will run in the worker. Only one instance will be triggered until it starts or completes.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescriptionThe single-runner task constructor without Worker and Runnable.- SingleRetriggerableTask- (Worker worker) The single-runner task constructor without Runnable.- SingleRetriggerableTask- (Worker worker, Runnable runnable) The single-runner task constructor.- SingleRetriggerableTask- (Runnable runnable) The single-runner task constructor without Worker.
- Method SummaryModifier and TypeMethodDescription- int- cancelTask- (boolean interruptTaskThread) Cancels the task.- booleanReturns if the runnable has been triggered.- void- setPriority- (int priority) Sets the priority of the task that is by default- WorkerTask.PRIORITY_LOWEST.- void- setRunnable- (Runnable runnable) Assigns the Runnable.- voidSets the Worker for the task.- boolean- trigger()Triggers a task.
- Constructor Details- SingleRetriggerableTaskpublic SingleRetriggerableTask()The single-runner task constructor without Worker and Runnable.- The Worker must be provided later using - setWorker(Worker).- The runnable must be set using - setRunnable(Runnable).
- SingleRetriggerableTaskThe single-runner task constructor without Runnable.- The Runnable must be set using - setRunnable(Runnable).- Parameters:
- worker- The Worker to run the task in.
 
- SingleRetriggerableTaskThe single-runner task constructor without Worker.- Parameters:
- runnable- The runnable.
 
- SingleRetriggerableTaskThe single-runner task constructor.- Parameters:
- worker- The Worker to run the task in.
- runnable- The Runnable to execute.
 
 
- Method Details- setPrioritypublic void setPriority- (int priority) Sets the priority of the task that is by default- WorkerTask.PRIORITY_LOWEST.- Parameters:
- priority- The new priority of coming tasks to run, range from lowest- WorkerTask.PRIORITY_LOWESTto highest- WorkerTask.PRIORITY_HIGHEST.
- Throws:
- IllegalArgumentException- If priority is out of range.
 
- setWorkerSets the Worker for the task.- Parameters:
- worker- The Worker to run the task in.
 
- setRunnableAssigns the Runnable.- Parameters:
- runnable- The Runnable to execute.
 
- isTriggeredpublic boolean isTriggered()Returns if the runnable has been triggered.- Returns:
- true if triggered, false otherwise.
 
- cancelTaskpublic int cancelTask- (boolean interruptTaskThread) Cancels the task.- Parameters:
- interruptTaskThread- Flag indicating if the task thread should be interrupted (if running) with call to- thread.interrupt();.
- Returns:
- 1 for success, zero for no task and -1 for failure.
 
- triggerpublic boolean trigger()Triggers a task.- Returns:
- true If the task has been posted, false if already posted.
- Throws:
- NullPointerException- If the Worker is- null.
- NullPointerException- If the Runnable is- null.