Class DefaultAsyncFutureTask<T>

  • All Implemented Interfaces:
    AsyncFuture<T>, AsyncPromise<T>, Time.Awaitable, java.lang.Runnable, java.util.concurrent.CompletionStage<T>, java.util.concurrent.Future<T>, java.util.concurrent.RunnableFuture<T>

    public class DefaultAsyncFutureTask<T>
    extends DefaultAsyncFuture<T>
    implements java.util.concurrent.RunnableFuture<T>
    Wraps a Callable in a FutureTask and make it notify a DefaultAsyncFuture.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture

        java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultAsyncFutureTask​(java.util.concurrent.Callable<T> callable, boolean cancellable)
      Wrap a callable in an AsyncFuture.
      DefaultAsyncFutureTask​(java.util.concurrent.Executor executor, java.util.concurrent.Callable<T> callable, boolean cancellable)  
      DefaultAsyncFutureTask​(java.util.concurrent.ExecutorService executor, java.util.concurrent.Callable<T> callable, boolean cancellable)
      Wrap a callable in an AsyncFuture and then submit it to be executed on the provided ExecutorService.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      void run()
      Run the Callable.
      protected boolean runAndReset()  
      • Methods inherited from class java.util.concurrent.CompletableFuture

        acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, completeAsync, completeAsync, completedFuture, completedStage, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, failedFuture, failedStage, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.CompletionStage

        acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsync
      • Methods inherited from interface java.util.concurrent.Future

        get, get, isCancelled, isDone
    • Constructor Detail

      • DefaultAsyncFutureTask

        public DefaultAsyncFutureTask​(java.util.concurrent.Callable<T> callable,
                                      boolean cancellable)
        Wrap a callable in an AsyncFuture. This constructor does not execute the callable so run() will need to be executed.
        Parameters:
        callable -
        cancellable -
      • DefaultAsyncFutureTask

        public DefaultAsyncFutureTask​(java.util.concurrent.ExecutorService executor,
                                      java.util.concurrent.Callable<T> callable,
                                      boolean cancellable)
        Wrap a callable in an AsyncFuture and then submit it to be executed on the provided ExecutorService.
        Parameters:
        executor -
        callable -
        cancellable -
      • DefaultAsyncFutureTask

        public DefaultAsyncFutureTask​(java.util.concurrent.Executor executor,
                                      java.util.concurrent.Callable<T> callable,
                                      boolean cancellable)
    • Method Detail

      • runAndReset

        protected boolean runAndReset()
      • run

        public void run()
        Run the Callable. If the Callable has already been executed or submitted to an Executor, this may cause an IllegalStateException to be thrown.
        Specified by:
        run in interface java.lang.Runnable
        Specified by:
        run in interface java.util.concurrent.RunnableFuture<T>
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
        Overrides:
        cancel in class DefaultAsyncFuture<T>
        See Also:
        Future.cancel(boolean)