Package org.jtrim2.executor
Class AbstractTaskExecutor.SubmittedTask<V>
java.lang.Object
org.jtrim2.executor.AbstractTaskExecutor.SubmittedTask<V>
- Type Parameters:
V- the type of the returned value of the submitted function
- Enclosing class:
- AbstractTaskExecutor
Defines the submitted task to be executed by subclasses of
AbstractTaskExecutor.
Implementations of AbstractTaskExecutor must eventually complete the SubmittedTask
in a way: execute,
completeExceptionally or cancel.
-
Constructor Summary
ConstructorsConstructorDescriptionSubmittedTask(CancelableFunction<? extends V> function) Creates a newSubmittedTaskwith the given underlying function. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Completes the submitted task exceptionally with anOperationCanceledException.voidCompletes the submitted task exceptionally with the given exception.voidexecute(CancellationToken cancelToken) Executes the submitted tasks and completes thisSubmittedTask.Returns the future of the submitted task.
-
Constructor Details
-
SubmittedTask
Creates a newSubmittedTaskwith the given underlying function.- Parameters:
function- the actual function to be calculated. This argument cannot benull.
-
-
Method Details
-
execute
Executes the submitted tasks and completes thisSubmittedTask. This method never throws an exception. If the submitted task fails, the task will be completed exceptionally.- Parameters:
cancelToken- theCancellationTokenpassed to the submitted task. This argument cannot benull.
-
getFuture
Returns the future of the submitted task.- Returns:
- the future of the submitted task. This method never returns
null.
-
completeExceptionally
Completes the submitted task exceptionally with the given exception.- Parameters:
ex- the exception to complete the submitted task with. This argument cannot benull.
-
cancel
public void cancel()Completes the submitted task exceptionally with anOperationCanceledException.
-