Class AbstractTask

  • All Implemented Interfaces:
    Task, TaskFunction

    public abstract class AbstractTask
    extends Object
    implements Task
    Skeletal implementation of a stateful Task.
    • Field Detail

      • taskContext

        protected TaskContext taskContext
        Context used to manage this Task; null if this Task is not bound to an execution Stage.
    • Constructor Detail

      • AbstractTask

        public AbstractTask()
    • Method Detail

      • taskContext

        public final TaskContext taskContext()
        Description copied from interface: Task
        Returns the context used to managed this Task. Returns null if this Task is not bound to a Stage.
        Specified by:
        taskContext in interface Task
      • setTaskContext

        public void setTaskContext​(TaskContext taskContext)
        Description copied from interface: Task
        Sets the context used to managed this Task. A TaskContext is assigned when binding this Task to a Stage.
        Specified by:
        setTaskContext in interface Task
      • runTask

        public abstract void runTask()
        Description copied from interface: Task
        Executes this sequential process. Only one thread at a time will execute runTask for this Task.
        Specified by:
        runTask in interface Task
        Specified by:
        runTask in interface TaskFunction
      • taskWillBlock

        public boolean taskWillBlock()
        Description copied from interface: Task
        Returns true if this Task might block its thread of execution when running; returns false if this Task will never block. Used by the execution Stage to prevent thread starvation when concurrently running many blocking tasks.
        Specified by:
        taskWillBlock in interface Task
      • taskWillCue

        public void taskWillCue()
        Description copied from interface: Task
        Lifecycle callback invoked before this Task is scheduled for execution.
        Specified by:
        taskWillCue in interface Task
      • taskDidCancel

        public void taskDidCancel()
        Description copied from interface: Task
        Lifecycle callback invoked after this Task is explicitly cancelled.
        Specified by:
        taskDidCancel in interface Task
      • isCued

        public boolean isCued()
        Returns true if the task is currently scheduled for execution. Delegates to the assigned taskContext, if set; otherwise returns false.
      • cue

        public boolean cue()
        Schedules this task to execute as a sequential process. Returns true if this operation caused the scheduling of this task; returns false if this task was already scheduled to execute. This task becomes uncued prior to the the invocation of runTask(), enabling this task to re-cue itself while running. Delegates to the assigned taskContext.
        Throws:
        TaskException - if taskContext is null.
      • cancel

        public boolean cancel()
        Cancels this task to prevent it from executing. Returns true if this operation caused the cancellation of this task; returns false if this task was not scheduled to execute. Delegates to the assigned taskContext.