Package dev.failsafe

Interface Timeout<R>

Type Parameters:
R - result type
All Superinterfaces:
Policy<R>
All Known Implementing Classes:
TimeoutImpl

public interface Timeout<R> extends Policy<R>
A policy that cancels and fails an excecution with a TimeoutExceededException if a timeout is exceeded. Execution interruption is optionally supported. Asynchronous executions are cancelled by calling cancel on their underlying future. Executions can internally cooperate with cancellation by checking ExecutionContext.isCancelled().

This policy uses a separate thread on the configured scheduler or the common pool to perform timeouts checks.

The PolicyBuilder.onFailure(EventListener) and PolicyBuilder.onSuccess(EventListener) event handlers can be used to handle a timeout being exceeded or not.

Note: interruption will have no effect when performing an async execution since the async thread is unknown to Failsafe.

This class is threadsafe.

See Also: