-
- All Superinterfaces:
TaskFunction
- All Known Implementing Classes:
AbstractTask
,AgentModel
,AgentNode
,MetaEdgeAgent
,MetaHostAgent
,MetaLaneAgent
,MetaMeshAgent
,MetaPartAgent
public interface Task extends TaskFunction
StatefulTaskFunction
to invoke as a sequential process on a concurrent executionStage
, with lifecycle callbacks, and aTaskContext
for self-management. UseStage.task(TaskFunction)
to bind a newTask
to aStage
, and invokeTaskRef.cue()
to schedule the concurrent execution of the sequential task.Blocking
Task
implementations should not perform long running or blocking operations, if possible. If aTask
does need to block, it should returntrue
fromtaskWillBlock()
to avoid thread starvation of the executionStage
.- See Also:
AbstractTask
,Stage
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
runTask()
Executes this sequential process.void
setTaskContext(TaskContext taskContext)
Sets the context used to managed thisTask
.TaskContext
taskContext()
Returns the context used to managed thisTask
.void
taskDidCancel()
Lifecycle callback invoked after thisTask
is explicitly cancelled.boolean
taskWillBlock()
Returnstrue
if thisTask
might block its thread of execution when running; returnsfalse
if thisTask
will never block.void
taskWillCue()
Lifecycle callback invoked before thisTask
is scheduled for execution.
-
-
-
Method Detail
-
taskContext
TaskContext taskContext()
-
setTaskContext
void setTaskContext(TaskContext taskContext)
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.
-
-