Class SyncExecutionImpl<R>
java.lang.Object
dev.failsafe.ExecutionImpl<R>
dev.failsafe.SyncExecutionImpl<R>
- Type Parameters:
R- result type
- All Implemented Interfaces:
Execution<R>, ExecutionContext<R>, ExecutionInternal<R>, SyncExecutionInternal<R>
SyncExecution and SyncExecutionInternal implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate final Threadprivate final FailsafeExecutor<R> private final AtomicBooleanprivate final AtomicBooleanprivate Function<SyncExecutionInternal<R>, ExecutionResult<R>> Fields inherited from class ExecutionImpl
attemptRecorded, cancelCallback, cancelledIndex, completed, policyExecutors, result -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)SyncExecutionImpl(FailsafeExecutor<R> executor, Scheduler scheduler, CallImpl<R> call, Function<SyncExecutionInternal<R>, ExecutionResult<R>> innerFn) Create a sync execution for theexecutor.privateSyncExecutionImpl(SyncExecutionImpl<R> execution) Create a sync execution for a new attempt.(package private)SyncExecutionImpl(List<? extends Policy<R>> policies) Create a standalone sync execution for thepolicies. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Records and completes the execution successfully.copy()Returns a new copy of the SyncExecutionInternal if it is not standalone, else returnsthissince standalone executions are referenced externally and cannot be replaced.(package private) RPerforms a synchronous execution.getDelay()Returns the time to delay before the next execution attempt.voidInterrupts the execution.booleanReturns whether the execution is complete or if it can be retried.booleanReturns whether the execution is currently interrupted.private boolean(package private) ExecutionResult<R> postExecute(ExecutionResult<R> result) Externally called.voidCalled when execution of the user's supplier is about to begin.voidRecords an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordException(Throwable exception) Records anexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordResult(R result) Records an executionresultwhich triggers failure handling, if needed, by the configured policies.voidsetInterruptable(boolean interruptable) Sets whether the execution is currentlyinterruptable.Methods inherited from class ExecutionImpl
cancel, cancel, getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getLatest, getLock, getResult, getStartTime, isCancelled, isCancelled, isFirstAttempt, isPreExecuted, isRetry, onCancel, record, recordAttempt, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ExecutionContext
getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getStartTime, isCancelled, isFirstAttempt, isRetry, onCancelMethods inherited from interface ExecutionInternal
cancel, cancel, getLatest, getLock, getResult, isCancelled, isPreExecuted, record, recordAttempt
-
Field Details
-
executor
-
call
-
outerFn
-
executionThread
-
interruptable
-
interrupted
-
delayNanos
private volatile long delayNanos
-
-
Constructor Details
-
SyncExecutionImpl
-
SyncExecutionImpl
SyncExecutionImpl(FailsafeExecutor<R> executor, Scheduler scheduler, CallImpl<R> call, Function<SyncExecutionInternal<R>, ExecutionResult<R>> innerFn) Create a sync execution for theexecutor. -
SyncExecutionImpl
Create a sync execution for a new attempt.
-
-
Method Details
-
complete
-
isComplete
public boolean isComplete()Description copied from interface:ExecutionReturns whether the execution is complete or if it can be retried. An execution is considered complete only when all configured policies consider the execution complete.- Specified by:
isCompletein interfaceExecution<R>
-
getDelay
-
record
Description copied from interface:ExecutionRecords an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed. -
recordResult
Description copied from interface:ExecutionRecords an executionresultwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.- Specified by:
recordResultin interfaceExecution<R>
-
recordException
Description copied from interface:ExecutionRecords anexceptionwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.- Specified by:
recordExceptionin interfaceExecution<R>
-
preExecute
public void preExecute()Description copied from interface:ExecutionInternalCalled when execution of the user's supplier is about to begin.- Specified by:
preExecutein interfaceExecutionInternal<R>- Overrides:
preExecutein classExecutionImpl<R>
-
postExecute
Description copied from class:ExecutionImplExternally called. Records an execution and performs post-execution handling for theresultagainst all configured policy executors. Returns whether the result is complete for all policies.- Overrides:
postExecutein classExecutionImpl<R>
-
isInterrupted
public boolean isInterrupted()Description copied from interface:SyncExecutionInternalReturns whether the execution is currently interrupted.- Specified by:
isInterruptedin interfaceSyncExecutionInternal<R>
-
setInterruptable
public void setInterruptable(boolean interruptable) Description copied from interface:SyncExecutionInternalSets whether the execution is currentlyinterruptable.- Specified by:
setInterruptablein interfaceSyncExecutionInternal<R>
-
interrupt
public void interrupt()Description copied from interface:SyncExecutionInternalInterrupts the execution.- Specified by:
interruptin interfaceSyncExecutionInternal<R>
-
isStandalone
private boolean isStandalone() -
copy
Description copied from interface:SyncExecutionInternalReturns a new copy of the SyncExecutionInternal if it is not standalone, else returnsthissince standalone executions are referenced externally and cannot be replaced.- Specified by:
copyin interfaceSyncExecutionInternal<R>
-
executeSync
R executeSync()Performs a synchronous execution.
-