public interface Futures
CompletionStage
.Modifier and Type | Method and Description |
---|---|
<A> java.util.concurrent.CompletionStage<A> |
delayed(java.util.concurrent.CompletionStage<A> stage,
java.time.Duration duration)
Create a CompletionStage which, after a delay, will be redeemed with the result of a
given supplier.
|
<A> java.util.concurrent.CompletionStage<A> |
delayed(java.util.concurrent.CompletionStage<A> stage,
long amount,
java.util.concurrent.TimeUnit unit)
Create a CompletionStage which, after a delay, will be redeemed with the result of a
given supplier.
|
static <A> java.util.concurrent.CompletionStage<A> |
delayed(java.util.function.Supplier<A> supplier,
long delay,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.Executor executor)
Deprecated.
Use injected
play.libs.concurrent.Futures.delayed , since 2.6.0 |
static <A> java.util.concurrent.CompletionStage<java.util.List<A>> |
sequence(java.util.concurrent.CompletionStage<A>... promises)
Combine the given CompletionStages into a single CompletionStage for the list of results.
|
static <A> java.util.concurrent.CompletionStage<java.util.List<A>> |
sequence(java.lang.Iterable<? extends java.util.concurrent.CompletionStage<A>> promises)
Combine the given CompletionStages into a single CompletionStage for the list of results.
|
static <A> java.util.concurrent.CompletionStage<A> |
timeout(A value,
long amount,
java.util.concurrent.TimeUnit unit)
Deprecated.
Use injected
play.libs.concurrent.Futures.timeout , since 2.6.0 |
<A> java.util.concurrent.CompletionStage<A> |
timeout(java.util.concurrent.CompletionStage<A> stage,
java.time.Duration duration)
An alias for futures(stage, delay, unit) that uses a java.time.Duration.
|
<A> java.util.concurrent.CompletionStage<A> |
timeout(java.util.concurrent.CompletionStage<A> stage,
long amount,
java.util.concurrent.TimeUnit unit)
Creates a CompletionStage that returns either the input stage, or a futures.
|
static <A> java.util.concurrent.CompletionStage<A> |
timeout(long delay,
java.util.concurrent.TimeUnit unit)
Deprecated.
Use injected
play.libs.concurrent.Futures.timeout , since 2.6.0 |
<A> java.util.concurrent.CompletionStage<A> timeout(java.util.concurrent.CompletionStage<A> stage, long amount, java.util.concurrent.TimeUnit unit)
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.<A> java.util.concurrent.CompletionStage<A> timeout(java.util.concurrent.CompletionStage<A> stage, java.time.Duration duration)
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.<A> java.util.concurrent.CompletionStage<A> delayed(java.util.concurrent.CompletionStage<A> stage, long amount, java.util.concurrent.TimeUnit unit)
A
- the type of the completion's result.stage
- the input completion stage that is delayed.amount
- The time to wait.unit
- The units to use for the amount.<A> java.util.concurrent.CompletionStage<A> delayed(java.util.concurrent.CompletionStage<A> stage, java.time.Duration duration)
A
- the type of the completion's result.stage
- the input completion stage that is delayed.duration
- to wait.static <A> java.util.concurrent.CompletionStage<java.util.List<A>> sequence(java.lang.Iterable<? extends java.util.concurrent.CompletionStage<A>> promises)
A
- the type of the completion's result.promises
- The CompletionStages to combinestatic <A> java.util.concurrent.CompletionStage<java.util.List<A>> sequence(java.util.concurrent.CompletionStage<A>... promises)
A
- the type of the completion's result.promises
- The CompletionStages to combine@Deprecated static <A> java.util.concurrent.CompletionStage<A> timeout(A value, long amount, java.util.concurrent.TimeUnit unit)
play.libs.concurrent.Futures.timeout
, since 2.6.0A
- the type of the completion's result.value
- The result value to use to complete the CompletionStage.amount
- The amount (expressed with the corresponding unit).unit
- The time unit, i.e. java.util.concurrent.TimeUnit.MILLISECONDS@Deprecated static <A> java.util.concurrent.CompletionStage<A> timeout(long delay, java.util.concurrent.TimeUnit unit)
play.libs.concurrent.Futures.timeout
, since 2.6.0completionStage.applyToEither(Futures.timeout(delay, unit), Function.identity())
The underlying implementation uses TimerTask, which has a
resolution in milliseconds.
A previous implementation used CompletionStage<Void>
which made
it unsuitable for composition. Cast with Futures.<Void>timeout
if
necessary.A
- the type of the completion's result.delay
- The delay (expressed with the corresponding unit).unit
- The time Unit.@Deprecated static <A> java.util.concurrent.CompletionStage<A> delayed(java.util.function.Supplier<A> supplier, long delay, java.util.concurrent.TimeUnit unit, java.util.concurrent.Executor executor)
play.libs.concurrent.Futures.delayed
, since 2.6.0A
- the type of the completion's result.supplier
- The supplier to call to fulfill the CompletionStage.delay
- The time to wait.unit
- The units to use for the delay.executor
- The executor to run the supplier in.