Interface Task<T>
-
- Type Parameters:
T
- the type of result produced by theTask
- All Superinterfaces:
ExternalizableLite
,Serializable
public interface Task<T> extends ExternalizableLite
A task which may take a long time to execute, may be executed by multipleExecutor
s, may generate intermediate results, and may yield for later execution.Implementations define a single method called
execute(Context)
that performs the task, possibly yielding execution to some later point. Once the method has completed execution, by returning a result or throwing an exception (but not a Yield exception), the task is considered completed for the assignedExecutor
.Task
s are likeCallable
andRunnable
classes in that they are designed to be potentially executed by one or moreThread
s, typicallyExecutor
s. UnlikeCallable
andRunnable
classes, the execution may occur in Java Virtual Machines, fail and/or recover between different Java Virtual Machine processes. As such, it is recommended to account for fail-over if a task is recovered. Important execution state should be saved in the in theTask.Context
properties
. Tasks should checkTask.Context.isResuming()
to determine if the task has failed over to another executor and if execution state should be recovered from theTask.Context
properties
.- Since:
- 21.12
- Author:
- bo
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Task.Collectable<T,R>
Provides the mechanism to submit, orchestrate and collect results from aTask
defined as part of anTask.Orchestration
, including the creation of aTask.Coordinator
to subscribe to results, manage and interact with an orchestratedTask
.static interface
Task.Collector<T,A,R>
A mutable reduction operation that accumulates results into a mutable result container, optionally transforming the accumulated result into a final representation after all results have been processed.static interface
Task.Completable<T,R>
ATask.Collectable
that supports performing operations when aTask
orchestration is complete.static interface
Task.CompletionRunnable<T>
A runnable to be called upon task completion.static interface
Task.Context<T>
static interface
Task.Coordinator<T>
static interface
Task.Option
An option for configuringTask
orchestration.static interface
Task.Orchestration<T>
static interface
Task.Properties
Define an interface to allow states sharing between the task executors.static interface
Task.SubscribedOrchestration<T>
Defines the subset ofTask.Orchestration
methods which are permitted afterTask.SubscribedOrchestration.subscribe(Subscriber)
is called.static interface
Task.Subscriber<T>
A receiver of items produced by aTask.Coordinator
.static interface
Task.Subscription<T>
Represents a subscription aTask.Subscriber
has made to aTask.Coordinator
, allowing control and termination of theTask.Subscription
.static class
Task.Yield
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
execute(Task.Context<T> context)
Executes theTask
.-
Methods inherited from interface com.tangosol.io.ExternalizableLite
readExternal, writeExternal
-
-
-
-
Method Detail
-
execute
T execute(Task.Context<T> context) throws Exception
Executes theTask
.- Parameters:
context
- theTask.Context
- Returns:
- the result of executing the
Task
- Throws:
Task.Yield
- which indicates theTask
execution should yield execution until some later point in timeException
-
-