Package dev.failsafe.spi
Interface ExecutionInternal<R>
- Type Parameters:
R
- result type
- All Superinterfaces:
ExecutionContext<R>
- All Known Subinterfaces:
AsyncExecutionInternal<R>
,SyncExecutionInternal<R>
- All Known Implementing Classes:
AsyncExecutionImpl
,ExecutionImpl
,SyncExecutionImpl
Internal execution APIs.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel()
Marks the execution as having been cancelled externally, which will cancel pending executions of all policies.void
cancel
(PolicyExecutor<R> policyExecutor) Marks the execution as having been cancelled by thepolicyExecutor
, which will also cancel pending executions of any inner policies of thepolicyExecutor
.Returns the most recent execution to be attempted.getLock()
Returns a lock object that is common across all execution attempts.Returns the recorded result for an execution attempt.boolean
isCancelled
(PolicyExecutor<R> policyExecutor) Returns whether the execution is considered cancelled for thepolicyExecutor
.boolean
Returns whether the execution has been pre-executed, indicating the attempt has started.void
Called when execution of the user's supplier is about to begin.void
record
(ExecutionResult<R> result) Records theresult
if the execution has beenpre-executed
and a result has not already been recorded.void
Records an execution attempt which may correspond with an execution result.Methods inherited from interface dev.failsafe.ExecutionContext
getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getStartTime, isCancelled, isFirstAttempt, isRetry, onCancel
-
Method Details
-
getResult
ExecutionResult<R> getResult()Returns the recorded result for an execution attempt. -
preExecute
void preExecute()Called when execution of the user's supplier is about to begin. -
isPreExecuted
boolean isPreExecuted()Returns whether the execution has been pre-executed, indicating the attempt has started. -
recordAttempt
void recordAttempt()Records an execution attempt which may correspond with an execution result. Async executions will have results recorded separately. -
record
Records theresult
if the execution has beenpre-executed
and a result has not already been recorded. -
cancel
boolean cancel()Marks the execution as having been cancelled externally, which will cancel pending executions of all policies.- Returns:
- whether cancellation was successful or not. Returns
false
if the execution was already cancelled or completed.
-
cancel
Marks the execution as having been cancelled by thepolicyExecutor
, which will also cancel pending executions of any inner policies of thepolicyExecutor
. Outer policies of thepolicyExecutor
will be unaffected. -
isCancelled
Returns whether the execution is considered cancelled for thepolicyExecutor
. -
getLock
Object getLock()Returns a lock object that is common across all execution attempts. Useful for guarding against races when mutating an execution. -
getLatest
ExecutionInternal<R> getLatest()Returns the most recent execution to be attempted.
-