- java.lang.Object
- 
- swim.concurrent.AbstractTask
 
- 
- All Implemented Interfaces:
- Task,- TaskFunction
 
 public abstract class AbstractTask extends Object implements Task Skeletal implementation of a statefulTask.
- 
- 
Field SummaryFields Modifier and Type Field Description protected TaskContexttaskContext
 - 
Constructor SummaryConstructors Constructor Description AbstractTask()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancancel()Cancels this task to prevent it from executing.booleancue()Schedules this task to execute as a sequential process.booleanisCued()Returnstrueif the task is currently scheduled for execution.abstract voidrunTask()Executes this sequential process.voidsetTaskContext(TaskContext taskContext)Sets the context used to managed thisTask.Stagestage()Returns the executionStageto which this task is bound.TaskContexttaskContext()Returns the context used to managed thisTask.voidtaskDidCancel()Lifecycle callback invoked after thisTaskis explicitly cancelled.booleantaskWillBlock()Returnstrueif thisTaskmight block its thread of execution when running; returnsfalseif thisTaskwill never block.voidtaskWillCue()Lifecycle callback invoked before thisTaskis scheduled for execution.
 
- 
- 
- 
Field Detail- 
taskContextprotected TaskContext taskContext 
 
- 
 - 
Method Detail- 
taskContextpublic final TaskContext taskContext() Description copied from interface:Task- Specified by:
- taskContextin interface- Task
 
 - 
setTaskContextpublic void setTaskContext(TaskContext taskContext) Description copied from interface:TaskSets the context used to managed thisTask. ATaskContextis assigned when binding thisTaskto aStage.- Specified by:
- setTaskContextin interface- Task
 
 - 
runTaskpublic abstract void runTask() Description copied from interface:TaskExecutes this sequential process. Only one thread at a time will executerunTaskfor thisTask.- Specified by:
- runTaskin interface- Task
- Specified by:
- runTaskin interface- TaskFunction
 
 - 
taskWillBlockpublic boolean taskWillBlock() Description copied from interface:TaskReturnstrueif thisTaskmight block its thread of execution when running; returnsfalseif thisTaskwill never block. Used by the executionStageto prevent thread starvation when concurrently running many blocking tasks.- Specified by:
- taskWillBlockin interface- Task
 
 - 
taskWillCuepublic void taskWillCue() Description copied from interface:TaskLifecycle callback invoked before thisTaskis scheduled for execution.- Specified by:
- taskWillCuein interface- Task
 
 - 
taskDidCancelpublic void taskDidCancel() Description copied from interface:TaskLifecycle callback invoked after thisTaskis explicitly cancelled.- Specified by:
- taskDidCancelin interface- Task
 
 - 
stagepublic Stage stage() Returns the executionStageto which this task is bound. Delegates to the assignedtaskContext.- Throws:
- TaskException- if- taskContextis- null.
 
 - 
isCuedpublic boolean isCued() Returnstrueif the task is currently scheduled for execution. Delegates to the assignedtaskContext, if set; otherwise returnsfalse.
 - 
cuepublic boolean cue() Schedules this task to execute as a sequential process. Returnstrueif this operation caused the scheduling of this task; returnsfalseif this task was already scheduled to execute. This task becomes uncued prior to the the invocation ofrunTask(), enabling this task to re-cue itself while running. Delegates to the assignedtaskContext.- Throws:
- TaskException- if- taskContextis- null.
 
 - 
cancelpublic boolean cancel() Cancels this task to prevent it from executing. Returnstrueif this operation caused the cancellation of this task; returnsfalseif this task was not scheduled to execute. Delegates to the assignedtaskContext.
 
- 
 
-