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

public static final class AbstractTaskExecutor.SubmittedTask<V> extends Object
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.

See Also:
  • Constructor Details

    • SubmittedTask

      public SubmittedTask(CancelableFunction<? extends V> function)
      Creates a new SubmittedTask with the given underlying function.
      Parameters:
      function - the actual function to be calculated. This argument cannot be null.
  • Method Details

    • execute

      public void execute(CancellationToken cancelToken)
      Executes the submitted tasks and completes this SubmittedTask. This method never throws an exception. If the submitted task fails, the task will be completed exceptionally.
      Parameters:
      cancelToken - the CancellationToken passed to the submitted task. This argument cannot be null.
    • getFuture

      public CompletableFuture<V> getFuture()
      Returns the future of the submitted task.
      Returns:
      the future of the submitted task. This method never returns null.
    • completeExceptionally

      public void completeExceptionally(Throwable ex)
      Completes the submitted task exceptionally with the given exception.
      Parameters:
      ex - the exception to complete the submitted task with. This argument cannot be null.
    • cancel

      public void cancel()
      Completes the submitted task exceptionally with an OperationCanceledException.