Package dev.failsafe
Class TimeoutBuilder<R>
- Type Parameters:
R
- result type
- All Implemented Interfaces:
PolicyListeners<TimeoutBuilder<R>,
R>
Builds
Timeout
instances.
This class is not threadsafe.
- See Also:
-
Field Summary
Fields inherited from class dev.failsafe.PolicyBuilder
config
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class dev.failsafe.PolicyBuilder
onFailure, onSuccess
-
Constructor Details
-
TimeoutBuilder
TimeoutBuilder(Duration timeout) -
TimeoutBuilder
TimeoutBuilder(TimeoutConfig<R> config)
-
-
Method Details
-
build
Builds a newTimeout
using the builder's configuration. -
withInterrupt
Configures the policy to interrupt an execution in addition to cancelling it when the timeout is exceeded. For synchronous executions this is done by callingThread.interrupt()
on the execution's thread. For asynchronous executions this is done by callingFuture.cancel(true)
. Executions can internally cooperate with interruption by checkingThread.isInterrupted()
or by handlingInterruptedException
where available.Note: Only configure interrupts if the code being executed is designed to be interrupted.
Note: interruption will have no effect when performing an
async execution
since the async thread is unknown to Failsafe.
-