public interface Timeout
class MyClass implements play.libs.concurrent.Timeout {
CompletionStage<Double> callWithTimeout() {
return timeout(longRunningOperation(), Duration.ofSeconds(1));
}
}
Modifier and Type | Method and Description |
---|---|
default <A> java.util.concurrent.CompletionStage<A> |
timeout(java.util.concurrent.CompletionStage<A> stage,
java.time.Duration delay)
An alias for timeout(stage, delay, unit) that uses a java.time.Duration.
|
default <A> java.util.concurrent.CompletionStage<A> |
timeout(java.util.concurrent.CompletionStage<A> stage,
long delay,
java.util.concurrent.TimeUnit unit)
Creates a CompletionStage that returns either the input stage, or a timeout.
|
default <A> java.util.concurrent.CompletionStage<A> timeout(java.util.concurrent.CompletionStage<A> stage, long delay, java.util.concurrent.TimeUnit unit)
A
- the completion's result type.stage
- the input completion stage that may time out.delay
- The delay (expressed with the corresponding unit).unit
- The time Unit.default <A> java.util.concurrent.CompletionStage<A> timeout(java.util.concurrent.CompletionStage<A> stage, java.time.Duration delay)
A
- the completion stage that should be wrapped with a future.stage
- the input completion stage that may time out.delay
- The delay (expressed with the corresponding unit).