public class Futures
extends java.lang.Object
CompletionStage
.Constructor and Description |
---|
Futures() |
Modifier and Type | Method and Description |
---|---|
static <A> F.Promise<A> |
delayed(java.util.function.Supplier<A> supplier,
long delay,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.Executor executor)
Create a Promise which, after a delay, will be redeemed with the result of a
given supplier.
|
static <A> F.Promise<java.util.List<A>> |
sequence(java.util.concurrent.CompletionStage<A>... promises)
Combine the given promises into a single promise for the list of results.
|
static <A> F.Promise<java.util.List<A>> |
sequence(java.lang.Iterable<? extends java.util.concurrent.CompletionStage<A>> promises)
Combine the given promises into a single promise for the list of results.
|
static <A> F.Promise<A> |
timeout(A message,
long delay,
java.util.concurrent.TimeUnit unit)
Create a Promise that is redeemed after a timeout.
|
static F.Promise<java.lang.Void> |
timeout(long delay,
java.util.concurrent.TimeUnit unit)
Create a Promise timer that throws a PromiseTimeoutException after
a given timeout.
|
public static <A> F.Promise<java.util.List<A>> sequence(java.lang.Iterable<? extends java.util.concurrent.CompletionStage<A>> promises)
promises
- The promises to combinepublic static <A> F.Promise<java.util.List<A>> sequence(java.util.concurrent.CompletionStage<A>... promises)
promises
- The promises to combinepublic static <A> F.Promise<A> timeout(A message, long delay, java.util.concurrent.TimeUnit unit)
message
- The message to use to redeem the Promise.delay
- The delay (expressed with the corresponding unit).unit
- The Unit.public static F.Promise<java.lang.Void> timeout(long delay, java.util.concurrent.TimeUnit unit)
delay
- The delay (expressed with the corresponding unit).unit
- The Unit.public static <A> F.Promise<A> delayed(java.util.function.Supplier<A> supplier, long delay, java.util.concurrent.TimeUnit unit, java.util.concurrent.Executor executor)
supplier
- The supplier to call to fulfill the Promise.delay
- The time to wait.unit
- The units to use for the delay.executor
- The executor to run the supplier in.