Package com.yahoo.jdisc.handler
Class FutureCompletion
- All Implemented Interfaces:
CompletionHandler
,CompletionStage<Boolean>
,Future<Boolean>
This class provides an implementation of CompletionHandler
that allows you to wait for either completed()
or failed(Throwable)
to be called. If failed() was called, the corresponding Throwable will
be rethrown when calling either of the get() methods. Unless an exception is thrown, the get() methods will always
return Boolean.TRUE.
Notice that calling cancel(boolean)
throws an UnsupportedOperationException.
- Author:
- Simon Thoresen Hult
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(Runnable r, Executor e) final boolean
cancel
(boolean mayInterruptIfRunning) void
Invoked when an operation has completed.void
Invoked when an operation fails.final boolean
Methods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, 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
-
Constructor Details
-
FutureCompletion
public FutureCompletion()
-
-
Method Details
-
completed
public void completed()Description copied from interface:CompletionHandler
Invoked when an operation has completed. Notice that you MUST call either this orCompletionHandler.failed(Throwable)
to release the internalContainer
reference. Failure to do so will prevent the Container from ever shutting down.- Specified by:
completed
in interfaceCompletionHandler
-
failed
Description copied from interface:CompletionHandler
Invoked when an operation fails. Notice that you MUST call either this orCompletionHandler.completed()
to release the internalContainer
reference. Failure to do so will prevent the Container from ever shutting down.- Specified by:
failed
in interfaceCompletionHandler
- Parameters:
t
- The exception to indicate why the I/O operation failed.
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public final boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<Boolean>
- Overrides:
isCancelled
in classCompletableFuture<Boolean>
-
addListener
-