Package com.iizix

Class SingleRetriggerableTask


  • public class SingleRetriggerableTask
    extends java.lang.Object
    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 Detail

      • SingleRetriggerableTask

        public 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).

      • SingleRetriggerableTask

        public SingleRetriggerableTask​(Worker worker)
        The single-runner task constructor without Runnable.

        The Runnable must be set using setRunnable(Runnable).

        Parameters:
        worker - The Worker to run the task in.
      • SingleRetriggerableTask

        public SingleRetriggerableTask​(java.lang.Runnable runnable)
        The single-runner task constructor without Worker.
        Parameters:
        runnable - The runnable.
      • SingleRetriggerableTask

        public SingleRetriggerableTask​(Worker worker,
                                       java.lang.Runnable runnable)
        The single-runner task constructor.
        Parameters:
        worker - The Worker to run the task in.
        runnable - The Runnable to execute.
    • Method Detail

      • setWorker

        public void setWorker​(Worker worker)
        Sets the Worker for the task.
        Parameters:
        worker - The Worker to run the task in.
      • setRunnable

        public void setRunnable​(java.lang.Runnable runnable)
        Assigns the Runnable.
        Parameters:
        runnable - The Runnable to execute.
      • isTriggered

        public boolean isTriggered()
        Returns if the runnable has been triggered.
        Returns:
        true if triggered, false otherwise.
      • cancelTask

        public 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.
      • trigger

        public boolean trigger()
        Triggers a task.
        Returns:
        true If the task has been posted, false if already posted.
        Throws:
        java.lang.NullPointerException - If the Worker is null.
        java.lang.NullPointerException - If the Runnable is null.