- 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 TypeMethodDescriptionvoid
runTask()
Executes this sequential process.void
setTaskContext
(TaskContext taskContext) Sets the context used to managed thisTask
.Returns the context used to managed thisTask
.void
Lifecycle callback invoked after thisTask
is explicitly cancelled.boolean
Returnstrue
if thisTask
might block its thread of execution when running; returnsfalse
if thisTask
will never block.void
Lifecycle callback invoked before thisTask
is scheduled for execution.
-
Method Details
-
taskContext
TaskContext taskContext() -
setTaskContext
Sets the context used to managed thisTask
. ATaskContext
is assigned when binding thisTask
to aStage
. -
runTask
void runTask()Executes this sequential process. Only one thread at a time will executerunTask
for thisTask
.- Specified by:
runTask
in interfaceTaskFunction
-
taskWillBlock
boolean taskWillBlock()Returnstrue
if thisTask
might block its thread of execution when running; returnsfalse
if thisTask
will never block. Used by the executionStage
to prevent thread starvation when concurrently running many blocking tasks. -
taskWillCue
void taskWillCue()Lifecycle callback invoked before thisTask
is scheduled for execution. -
taskDidCancel
void taskDidCancel()Lifecycle callback invoked after thisTask
is explicitly cancelled.
-