Interface Task<T>

Type Parameters:
T - the type of result produced by the Task
All Superinterfaces:
ExternalizableLite, Serializable
All Known Implementing Classes:
CronTask, ValueTask

public interface Task<T> extends ExternalizableLite
A task which may take a long time to execute, may be executed by multiple Executors, 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 assigned Executor.

Tasks are like Callable and Runnable classes in that they are designed to be potentially executed by one or more Threads, typically Executors. Unlike Callable and Runnable 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 the Task.Context properties. Tasks should check Task.Context.isResuming() to determine if the task has failed over to another executor and if execution state should be recovered from the Task.Context properties.

Since:
21.12
Author:
bo