- All Superinterfaces:
TaskFunction
- All Known Implementing Classes:
AbstractTask,AgentModel,AgentNode,MetaEdgeAgent,MetaHostAgent,MetaLaneAgent,MetaMeshAgent,MetaPartAgent
Stateful
TaskFunction to invoke as a sequential process on a
concurrent execution Stage, with lifecycle callbacks, and a TaskContext for self-management. Use Stage.task(TaskFunction) to
bind a new Task to a Stage, and invoke TaskRef.cue()
to schedule the concurrent execution of the sequential task.
Blocking
Task implementations should not perform long running or blocking
operations, if possible. If a Task does need to block, it should
return true from taskWillBlock() to avoid thread starvation
of the execution Stage.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidrunTask()Executes this sequential process.voidsetTaskContext(TaskContext taskContext) Sets the context used to managed thisTask.Returns the context used to managed thisTask.voidLifecycle callback invoked after thisTaskis explicitly cancelled.booleanReturnstrueif thisTaskmight block its thread of execution when running; returnsfalseif thisTaskwill never block.voidLifecycle callback invoked before thisTaskis scheduled for execution.
-
Method Details
-
taskContext
TaskContext taskContext() -
setTaskContext
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.
-