Class DefaultAsyncFutureTask<T>
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<T>
-
- com.linkedin.alpini.base.concurrency.impl.DefaultAsyncFuture<T>
-
- com.linkedin.alpini.base.concurrency.impl.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>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
-
Nested classes/interfaces inherited from interface com.linkedin.alpini.base.concurrency.AsyncFuture
AsyncFuture.Status
-
-
Field Summary
-
Fields inherited from interface com.linkedin.alpini.base.concurrency.AsyncFuture
NULL_SUCCESS
-
-
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 com.linkedin.alpini.base.concurrency.impl.DefaultAsyncFuture
addListener, addListener, await, await, awaitUninterruptibly, awaitUninterruptibly, complete, completeExceptionally, get, getCause, getNow, isSuccess, setFailure, setSuccess
-
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 com.linkedin.alpini.base.concurrency.AsyncPromise
setComplete
-
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
-
-
-
-
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 interfacejava.lang.Runnable
- Specified by:
run
in interfacejava.util.concurrent.RunnableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<T>
- Overrides:
cancel
in classDefaultAsyncFuture<T>
- See Also:
Future.cancel(boolean)
-
-