R
- result typepublic class FailsafeFuture<R> extends CompletableFuture<R>
CompletableFuture.AsynchronousCompletionTask
Constructor and Description |
---|
FailsafeFuture(BiConsumer<ExecutionResult<R>,ExecutionContext<R>> completionHandler) |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Cancels the future along with any dependencies.
|
void |
cancelDependencies(PolicyExecutor<R> cancellingPolicyExecutor,
boolean mayInterrupt,
ExecutionResult<R> cancelResult)
Applies any
cancel functions with the cancelResult for
PolicyExecutors whose policyIndex is < the policyIndex of the cancellingPolicyExecutor . |
boolean |
complete(R value)
If not already completed, completes the future with the
value , calling the complete and success handlers. |
boolean |
completeExceptionally(Throwable exception)
If not already completed, completes the future with the
exception , calling the complete and failure
handlers. |
boolean |
completeResult(ExecutionResult<R> result)
Completes the execution with the
result and calls the completion handler. |
void |
propagateCancellation(Future<R> future)
Propogates any previous cancellation to the
future , either by cancelling it immediately or setting a cancel
function to cancel it later. |
void |
setCancelFn(int policyIndex,
BiConsumer<Boolean,ExecutionResult<R>> cancelFn)
Sets a
cancelFn to be called when a PolicyExecutor cancels dependencies with a policyIndex > the given policyIndex , or when this future is
cancelled . |
void |
setCancelFn(PolicyExecutor<R> policyExecutor,
BiConsumer<Boolean,ExecutionResult<R>> cancelFn)
Sets a
cancelFn to be called when a PolicyExecutor cancels dependencies with a policyIndex > the policyIndex of the given policyExecutor , or
when this future is cancelled . |
void |
setExecution(ExecutionInternal<R> execution)
Sets the
execution representing the most recent attempt, which will be cancelled if this future is
cancelled. |
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, completedFuture, exceptionally, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, obtrudeException, obtrudeValue, 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
public FailsafeFuture(BiConsumer<ExecutionResult<R>,ExecutionContext<R>> completionHandler)
public boolean complete(R value)
value
, calling the complete and success handlers.complete
in class CompletableFuture<R>
public boolean completeExceptionally(Throwable exception)
exception
, calling the complete and failure
handlers.completeExceptionally
in class CompletableFuture<R>
public boolean cancel(boolean mayInterruptIfRunning)
public boolean completeResult(ExecutionResult<R> result)
result
and calls the completion handler.public void cancelDependencies(PolicyExecutor<R> cancellingPolicyExecutor, boolean mayInterrupt, ExecutionResult<R> cancelResult)
cancel functions
with the cancelResult
for
PolicyExecutors whose policyIndex is < the policyIndex of the cancellingPolicyExecutor
.cancellingPolicyExecutor
- the PolicyExecutor that is requesting the cancellation of inner policy executorspublic void setExecution(ExecutionInternal<R> execution)
execution
representing the most recent attempt, which will be cancelled if this future is
cancelled.public void setCancelFn(int policyIndex, BiConsumer<Boolean,ExecutionResult<R>> cancelFn)
cancelFn
to be called when a PolicyExecutor cancels dependencies
with a policyIndex > the given policyIndex
, or when this future is
cancelled
.public void setCancelFn(PolicyExecutor<R> policyExecutor, BiConsumer<Boolean,ExecutionResult<R>> cancelFn)
cancelFn
to be called when a PolicyExecutor cancels dependencies
with a policyIndex > the policyIndex of the given policyExecutor
, or
when this future is cancelled
.Copyright © 2022. All rights reserved.