-
- All Superinterfaces:
TaskFunction
- All Known Implementing Classes:
AbstractTask,AgentModel,AgentNode,MetaEdgeAgent,MetaHostAgent,MetaLaneAgent,MetaMeshAgent,MetaPartAgent
public interface Task extends TaskFunction
StatefulTaskFunctionto invoke as a sequential process on a concurrent executionStage, with lifecycle callbacks, and aTaskContextfor self-management. UseStage.task(TaskFunction)to bind a newTaskto aStage, and invokeTaskRef.cue()to schedule the concurrent execution of the sequential task.Blocking
Taskimplementations should not perform long running or blocking operations, if possible. If aTaskdoes need to block, it should returntruefromtaskWillBlock()to avoid thread starvation of the executionStage.- See Also:
AbstractTask,Stage
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidrunTask()Executes this sequential process.voidsetTaskContext(TaskContext taskContext)Sets the context used to managed thisTask.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.
-
-
-
Method Detail
-
taskContext
TaskContext taskContext()
-
setTaskContext
void setTaskContext(TaskContext taskContext)
Sets the context used to managed thisTask. ATaskContextis assigned when binding thisTaskto aStage.
-
runTask
void runTask()
Executes this sequential process. Only one thread at a time will executerunTaskfor thisTask.- Specified by:
runTaskin interfaceTaskFunction
-
taskWillBlock
boolean taskWillBlock()
Returnstrueif 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.
-
taskWillCue
void taskWillCue()
Lifecycle callback invoked before thisTaskis scheduled for execution.
-
taskDidCancel
void taskDidCancel()
Lifecycle callback invoked after thisTaskis explicitly cancelled.
-
-