Constructor and Description |
---|
DefaultFutures(play.api.libs.concurrent.Futures delegate) |
Modifier and Type | Method and Description |
---|---|
CompletionStage<akka.Done> |
delay(Duration duration)
Creates a completion stage which is only completed after the delay.
|
CompletionStage<akka.Done> |
delay(long amount,
TimeUnit unit)
Creates a completion stage which is only completed after the delay.
|
<A> CompletionStage<A> |
delayed(Callable<CompletionStage<A>> callable,
Duration duration)
Create a CompletionStage which, after a delay, will be redeemed with the result of a given
supplier.
|
<A> CompletionStage<A> |
delayed(Callable<CompletionStage<A>> callable,
long amount,
TimeUnit unit)
Create a CompletionStage which, after a delay, will be redeemed with the result of a given
supplier.
|
<A> CompletionStage<A> |
timeout(CompletionStage<A> stage,
Duration duration)
An alias for futures(stage, delay, unit) that uses a java.time.Duration.
|
<A> CompletionStage<A> |
timeout(CompletionStage<A> stage,
long amount,
TimeUnit unit)
Creates a CompletionStage that returns either the input stage, or a futures.
|
@Inject public DefaultFutures(play.api.libs.concurrent.Futures delegate)
public <A> CompletionStage<A> timeout(CompletionStage<A> stage, long amount, TimeUnit unit)
Note that timeout is not the same as cancellation. Even in case of futures, the given completion stage will still complete, even though that completed value is not returned.
timeout
in interface Futures
A
- the completion's result type.stage
- the input completion stage that may time out.amount
- The amount (expressed with the corresponding unit).unit
- The time Unit.public <A> CompletionStage<A> timeout(CompletionStage<A> stage, Duration duration)
timeout
in interface Futures
A
- the completion stage that should be wrapped with a future.stage
- the input completion stage that may time out.duration
- The duration after which there is a timeout.public <A> CompletionStage<A> delayed(Callable<CompletionStage<A>> callable, long amount, TimeUnit unit)
public CompletionStage<akka.Done> delay(Duration duration)
Futures
Duration expected = Duration.ofSeconds(2);
long start = System.currentTimeMillis();
CompletionStage<Long> stage = futures.delay(expected).thenApply((v) -> {
long end = System.currentTimeMillis();
return (end - start);
});
public CompletionStage<akka.Done> delay(long amount, TimeUnit unit)
Futures
public <A> CompletionStage<A> delayed(Callable<CompletionStage<A>> callable, Duration duration)