/** * Combine the given CompletionStages into a single CompletionStage for the list of results. * * The sequencing operations are performed in the default ExecutionContext. * @param promises The CompletionStages to combine * @param <A> the type of the completion's result. * @return A single CompletionStage whose methods act on the list of redeemed CompletionStage */ @SafeVarargs static <A> CompletionStage<List<A>> sequence(CompletionStage<A>... promises) { return sequence(Arrays.asList(promises)); } }
/** * Create a Promise that is redeemed after a timeout. * * @param message The message to use to redeem the Promise. * @param delay The delay (expressed with the corresponding unit). * @param unit The Unit. * Use {@link Futures#timeout(Object, long, TimeUnit)} instead. */ public static <A> Promise<A> timeout(A message, long delay, TimeUnit unit) { return (Promise<A>) Futures.timeout(message, delay, unit); }
/** * Create a Promise which, after a delay, will be redeemed with the result of a * given function. The function will be called after the delay. * * @param function The function to call to fulfill the Promise. * @param delay The time to wait. * @param unit The units to use for the delay. * Use {@link Futures#delayed(Supplier, long, TimeUnit, Executor)} instead. */ public static <A> Promise<A> delayed(Supplier<A> function, long delay, TimeUnit unit, Executor ec) { return wrap(Futures.delayed(function, delay, unit, (ec))); }
/** * Create a Promise that is redeemed after a timeout. * * @param message The message to use to redeem the Promise. * @param delay The delay expressed in milliseconds. * Use {@link Futures#timeout(Object, long, TimeUnit)} instead. */ public static <A> Promise<A> timeout(A message, long delay) { return wrap(Futures.timeout(message, delay, TimeUnit.MILLISECONDS)); }
/** * Create a Promise which, after a delay, will be redeemed with the result of a * given function. The function will be called after the delay. * <p> * The function will be run in the default ExecutionContext. * * @param function The function to call to fulfill the Promise. * @param delay The time to wait. * @param unit The units to use for the delay. * Use {@link Futures#delayed(Supplier, long, TimeUnit, Executor)} with * {@link Execution#httpPromiseContext()} instead. */ public static <A> Promise<A> delayed(Supplier<A> function, long delay, TimeUnit unit) { return wrap(Futures.delayed(function, delay, unit, Execution.httpPromiseContext())); }
/** * Combine the given CompletionStages into a single CompletionStage for the list of results. * * The sequencing operations are performed in the default ExecutionContext. * @param promises The CompletionStages to combine * @param <A> the type of the completion's result. * @return A single CompletionStage whose methods act on the list of redeemed CompletionStage */ @SafeVarargs static <A> CompletionStage<List<A>> sequence(CompletionStage<A>... promises) { return sequence(Arrays.asList(promises)); } }
/** * Create a Promise timer that throws a PromiseTimeoutException after * a given timeout. * <p> * The returned Promise is usually combined with other Promises. * * @param delay The delay expressed in milliseconds. * Use {@link Futures#timeout(long, TimeUnit)} instead. * @return a promise without a real value */ public static Promise<Void> timeout(long delay) { return wrap(Futures.timeout(delay, TimeUnit.MILLISECONDS)); }
/** * Combine the given CompletionStages into a single CompletionStage for the list of results. * * The sequencing operations are performed in the default ExecutionContext. * @param promises The CompletionStages to combine * @param <A> the type of the completion's result. * @return A single CompletionStage whose methods act on the list of redeemed CompletionStage */ @SafeVarargs static <A> CompletionStage<List<A>> sequence(CompletionStage<A>... promises) { return sequence(Arrays.asList(promises)); } }
/** * Create a Promise timer that throws a PromiseTimeoutException after * a given timeout. * <p> * The returned Promise is usually combined with other Promises. * * @param delay The delay (expressed with the corresponding unit). * @param unit The Unit. * @return a promise without a real value * Use {@link Futures#timeout(long, TimeUnit)} instead. */ public static Promise<Void> timeout(long delay, TimeUnit unit) { return wrap(Futures.timeout(delay, unit)); }
/** * Combine the given promises into a single promise for the list of results. * <p> * The sequencing operations are performed in the default ExecutionContext. * * @param promises The promises to combine * @return A single promise whose methods act on the list of redeemed promises * Use {@link Futures#sequence(Iterable)} instead. */ public static <A> Promise<List<A>> sequence(Iterable<Promise<A>> promises) { return wrap(Futures.sequence(promises)); }
/** * Combine the given promises into a single promise for the list of results. * <p> * The sequencing operations are performed in the default ExecutionContext. * * @param promises The promises to combine * @return A single promise whose methods act on the list of redeemed promises * Use {@link Futures#sequence(CompletionStage[])} instead. */ public static <A> Promise<List<A>> sequence(Promise<A>... promises) { return wrap(Futures.sequence(Arrays.asList(promises))); }