Class Promises
Promises.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionall()Optimized for 2 promises.ReturnsPromisethat completes when all of thepromisesare completed.Returns aPromisethat completes when all of thepromisesare completed.static <T> Promise<T>any()Returns aCompleteExceptionallyPromisewithException, since this method doesn't accept anyPromisesstatic <T> Promise<T>static <T> Promise<T>static <T> Promise<T>Optimized for 2 promises.static <T> Promise<T>any(BiPredicate<? super T, Exception> predicate, Promise<? extends T> promise1) static <T> Promise<T>any(BiPredicate<? super T, Exception> predicate, Promise<? extends T>... promises) static <T> Promise<T>any(BiPredicate<? super T, Exception> predicate, Promise<? extends T> promise1, Promise<? extends T> promise2) static <T> Promise<T>any(BiPredicate<? super T, Exception> predicate, Iterator<? extends Promise<? extends T>> promises) static <T> Promise<T>any(BiPredicate<? super T, Exception> predicate, List<? extends Promise<? extends T>> promises) static <T> Promise<T>any(BiPredicate<? super T, Exception> predicate, Stream<? extends Promise<? extends T>> promises) static <T> Promise<T>static <T> Promise<T>static <T> Promise<T>asPromises(AsyncSupplier<? extends T>... tasks) asPromises(Iterable<? extends AsyncSupplier<? extends T>> tasks) asPromises(Iterator<? extends AsyncSupplier<? extends T>> tasks) asPromises(Stream<? extends AsyncSupplier<? extends T>> tasks) static <T,A, R> AsyncFunction<T, R> coalesce(Supplier<A> argumentAccumulatorSupplier, BiConsumer<A, T> argumentAccumulatorFn, AsyncFunction<A, R> fn) delay(long delayMillis) static <T> Promise<T>Delays completion of providedpromisefor the defined period of time.static <T> Promise<T>delay(long delayMillis, T value) delay(ReactorScheduler reactor, long delayMillis) static <T> Promise<T>delay(ReactorScheduler reactor, long delayMillis, Promise<T> promise) static <T> Promise<T>delay(ReactorScheduler reactor, long delayMillis, T value) delay(ReactorScheduler reactor, Duration delay) static <T> Promise<T>delay(ReactorScheduler reactor, Duration delay, Promise<T> promise) static <T> Promise<T>delay(ReactorScheduler reactor, Duration delay, T value) static <T> Promise<T>static <T> Promise<T>static <T> Promise<T>first(AsyncSupplier<? extends T>... promises) Picks the firstPromisethat was completed without exception.static <T> Promise<T>first(Iterable<? extends AsyncSupplier<? extends T>> promises) static <T> Promise<T>first(BiPredicate<? super T, ? super Exception> predicate, AsyncSupplier<? extends T>... promises) static <T> Promise<T>first(BiPredicate<? super T, ? super Exception> predicate, Iterable<? extends AsyncSupplier<? extends T>> promises) static <T> Promise<T>first(BiPredicate<? super T, ? super Exception> predicate, Iterator<? extends Promise<? extends T>> promises) static <T> Promise<T>first(BiPredicate<? super T, ? super Exception> predicate, Stream<? extends AsyncSupplier<? extends T>> promises) static <T> Promise<T>static <T> Promise<T>first(Stream<? extends AsyncSupplier<? extends T>> promises) static <T> Promise<T>static <T> Promise<T>interval(ReactorScheduler reactor, long intervalMillis, Promise<T> promise) static <T> Promise<T>interval(ReactorScheduler reactor, Duration interval, Promise<T> promise) static <T> Promise<T>static <T> Promise<T>Repeats providedFunctionExuntil can passPredicatetest.static <T,T1, R, R1>
AsyncFunction<T,R> mapTuple(io.activej.common.tuple.TupleConstructor1<R1, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1) static <T,T1, T2, R, R1, R2>
AsyncFunction<T,R> mapTuple(io.activej.common.tuple.TupleConstructor2<R1, R2, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2) static <T,T1, T2, T3, R, R1, R2, R3>
AsyncFunction<T,R> mapTuple(io.activej.common.tuple.TupleConstructor3<R1, R2, R3, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3) static <T,T1, T2, T3, T4, R, R1, R2, R3, R4>
AsyncFunction<T,R> mapTuple(io.activej.common.tuple.TupleConstructor4<R1, R2, R3, R4, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3, Function<? super T, T4> getter4, Function<T4, Promise<R4>> fn4) static <T,T1, T2, T3, T4, T5, R, R1, R2, R3, R4, R5>
AsyncFunction<T,R> mapTuple(io.activej.common.tuple.TupleConstructor5<R1, R2, R3, R4, R5, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3, Function<? super T, T4> getter4, Function<T4, Promise<R4>> fn4, Function<? super T, T5> getter5, Function<T5, Promise<R5>> fn5) static <T,T1, T2, T3, T4, T5, T6, R, R1, R2, R3, R4, R5, R6>
AsyncFunction<T,R> mapTuple(io.activej.common.tuple.TupleConstructor6<R1, R2, R3, R4, R5, R6, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3, Function<? super T, T4> getter4, Function<T4, Promise<R4>> fn4, Function<? super T, T5> getter5, Function<T5, Promise<R5>> fn5, Function<? super T, T6> getter6, Function<T6, Promise<R6>> fn6) static <T,A, R> Promise<R> reduce(A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, int maxCalls, Iterator<Promise<T>> promises) static <T,A, R> Promise<R> reduce(A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, Collection<Promise<T>> promises) static <T,A, R> Promise<R> reduce(A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, Iterator<Promise<T>> promises) static <T,A, R> Promise<R> reduce(A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, Stream<Promise<T>> promises) static <T,A, R> Promise<R> repeat(AsyncSupplier<Boolean> supplier) Repeats the operations of providedAsyncSupplier<Boolean>infinitely, until one of thePromises completes exceptionally or supplier returns a promise offalse.static <T> Promise<T>retry(AsyncSupplier<T> supplier) static <T> Promise<T>retry(AsyncSupplier<T> supplier, RetryPolicy<?> retryPolicy) static <T> Promise<T>retry(AsyncSupplier<T> supplier, BiPredicate<T, Exception> breakCondition, RetryPolicy<?> retryPolicy) static <T> Promise<T>retry(BiPredicate<? super T, Exception> breakCondition, AsyncSupplier<T> supplier) schedule(long timestamp) static <T> Promise<T>Schedules completion of thePromiseso that it will be completed after the timestamp even if its operations were completed earlier.static <T> Promise<T>schedule(long timestamp, T value) schedule(ReactorScheduler reactor, long timestamp) static <T> Promise<T>schedule(ReactorScheduler reactor, long timestamp, Promise<T> promise) static <T> Promise<T>schedule(ReactorScheduler reactor, long timestamp, T value) schedule(ReactorScheduler reactor, Instant instant) static <T> Promise<T>schedule(ReactorScheduler reactor, Instant instant, Promise<T> promise) static <T> Promise<T>schedule(ReactorScheduler reactor, Instant instant, T value) static <T> Promise<T>static <T> Promise<T>sequence()Returns aCompleteNullPromisesequence(AsyncRunnable runnable) Executes anAsyncRunnable, returning aPromise<Void>as a mark for completionsequence(AsyncRunnable... runnables) sequence(AsyncRunnable runnable1, AsyncRunnable runnable2) Executes bothAsyncRunnables consequently, returning aPromise<Void>as a mark for completionsequence(Iterable<? extends AsyncRunnable> runnables) Calls everyPromisefrompromisesin sequence and discards their results.Returns aSettablePromisewithnullresult as a marker when all of thepromisesare completed.sequence(Stream<? extends AsyncRunnable> runnables) static <T> Promise<T>Waits until the delay passes and if thePromiseis still not complete, tries to complete it withTIMEOUT_EXCEPTION.static <T> Promise<T>timeout(ReactorScheduler reactor, long delay, Promise<T> promise) static <T> Promise<T>timeout(ReactorScheduler reactor, Duration delay, Promise<T> promise) static <T> Promise<T>static <T> Promise<T[]>Returns an array of providedtypeand length 0 wrapped inPromise.static <T> Promise<T[]>Returns an array withpromise1result.static <T> Promise<T[]>static <T> Promise<T[]>Returns an array withpromise1andpromise2results.static <T> Promise<T[]>static <T> Promise<T[]>static <T> Promise<T[]>Reduces promises into Promise<Array>static <T> Promise<T[]>toList()Returns a successfully completedPromisewith an empty list as the result.Returns a completedPromisewith a result wrapped inList.ReturnsPromisewith a list ofpromise1andpromise2results.Reduces list ofPromises into Promise<List>.static <T1,R> Promise<R> toTuple(io.activej.common.tuple.TupleConstructor1<T1, R> constructor, Promise<? extends T1> promise1) static <T1,T2, R> Promise<R> toTuple(io.activej.common.tuple.TupleConstructor2<T1, T2, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2) static <T1,T2, T3, R>
Promise<R>toTuple(io.activej.common.tuple.TupleConstructor3<T1, T2, T3, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3) static <T1,T2, T3, T4, R>
Promise<R>toTuple(io.activej.common.tuple.TupleConstructor4<T1, T2, T3, T4, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4) static <T1,T2, T3, T4, T5, R>
Promise<R>toTuple(io.activej.common.tuple.TupleConstructor5<T1, T2, T3, T4, T5, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5) static <T1,T2, T3, T4, T5, T6, R>
Promise<R>toTuple(io.activej.common.tuple.TupleConstructor6<T1, T2, T3, T4, T5, T6, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5, Promise<? extends T6> promise6) static <T1> Promise<io.activej.common.tuple.Tuple1<T1>>static <T1,T2> Promise<io.activej.common.tuple.Tuple2<T1, T2>> static <T1,T2, T3> Promise<io.activej.common.tuple.Tuple3<T1, T2, T3>> toTuple(Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3) static <T1,T2, T3, T4>
Promise<io.activej.common.tuple.Tuple4<T1,T2, T3, T4>> toTuple(Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4) static <T1,T2, T3, T4, T5>
Promise<io.activej.common.tuple.Tuple5<T1,T2, T3, T4, T5>> toTuple(Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5) static <T1,T2, T3, T4, T5, T6>
Promise<io.activej.common.tuple.Tuple6<T1,T2, T3, T4, T5, T6>> toTuple(Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5, Promise<? extends T6> promise6) static <T> Promise<T>until(T seed, io.activej.common.function.FunctionEx<T, Promise<T>> next, Predicate<T> breakCondition)
-
Constructor Details
-
Promises
public Promises()
-
-
Method Details
-
timeout
- See Also:
-
timeout
-
timeout
Waits until the delay passes and if thePromiseis still not complete, tries to complete it withTIMEOUT_EXCEPTION.- Parameters:
delay- time of delaypromise- the Promise to be tracked- Returns:
Promise
-
timeout
-
delay
-
delay
-
delay
-
delay
-
delay
-
delay
-
delay
-
delay
-
delay
- See Also:
-
delay
-
delay
Delays completion of providedpromisefor the defined period of time.- Parameters:
delayMillis- delay in millispromise- thePromiseto be delayed- Returns:
- completed
Promise
-
delay
-
interval
-
interval
public static <T> Promise<T> interval(ReactorScheduler reactor, Duration interval, Promise<T> promise) -
interval
-
interval
public static <T> Promise<T> interval(ReactorScheduler reactor, long intervalMillis, Promise<T> promise) -
schedule
- See Also:
-
schedule
-
schedule
- See Also:
-
schedule
-
schedule
- See Also:
-
schedule
-
schedule
- See Also:
-
schedule
-
schedule
- See Also:
-
schedule
public static <T> Promise<T> schedule(ReactorScheduler reactor, Instant instant, Promise<T> promise) -
schedule
Schedules completion of thePromiseso that it will be completed after the timestamp even if its operations were completed earlier. -
schedule
-
all
- See Also:
-
all
- See Also:
-
all
Optimized for 2 promises.- See Also:
-
all
- See Also:
-
all
Returns aPromisethat completes when all of thepromisesare completed. -
all
- See Also:
-
all
ReturnsPromisethat completes when all of thepromisesare completed. If at least one of thepromisescompletes exceptionally, aCompleteExceptionallyPromisewill be returned. -
any
Returns aCompleteExceptionallyPromisewithException, since this method doesn't accept anyPromises- See Also:
-
any
- See Also:
-
any
@Contract(pure=true) public static <T> Promise<T> any(Promise<? extends T> promise1, Promise<? extends T> promise2) Optimized for 2 promises.- See Also:
-
any
@Contract(pure=true) @SafeVarargs public static <T> Promise<T> any(Promise<? extends T>... promises) - See Also:
-
any
@Contract(pure=true) public static <T> Promise<T> any(List<? extends Promise<? extends T>> promises) - See Also:
-
any
@Contract(pure=true) public static <T> Promise<T> any(Stream<? extends Promise<? extends T>> promises) - See Also:
-
any
-
any
@Contract(pure=true) public static <T> Promise<T> any(BiPredicate<? super T, Exception> predicate, Promise<? extends T> promise1) -
any
@Contract(pure=true) public static <T> Promise<T> any(BiPredicate<? super T, Exception> predicate, Promise<? extends T> promise1, Promise<? extends T> promise2) -
any
@Contract(pure=true) @SafeVarargs public static <T> Promise<T> any(BiPredicate<? super T, Exception> predicate, Promise<? extends T>... promises) -
any
@Contract(pure=true) public static <T> Promise<T> any(BiPredicate<? super T, Exception> predicate, Stream<? extends Promise<? extends T>> promises) -
any
@Contract(pure=true) public static <T> Promise<T> any(BiPredicate<? super T, Exception> predicate, List<? extends Promise<? extends T>> promises) -
any
public static <T> Promise<T> any(BiPredicate<? super T, Exception> predicate, Iterator<? extends Promise<? extends T>> promises) -
toList
Returns a successfully completedPromisewith an empty list as the result. -
toList
Returns a completedPromisewith a result wrapped inList. -
toList
@Contract(pure=true) public static <T> Promise<List<T>> toList(Promise<? extends T> promise1, Promise<? extends T> promise2) ReturnsPromisewith a list ofpromise1andpromise2results. -
toList
@Contract(pure=true) @SafeVarargs public static <T> Promise<List<T>> toList(Promise<? extends T>... promises) - See Also:
-
toList
@Contract(pure=true) public static <T> Promise<List<T>> toList(List<? extends Promise<? extends T>> promises) Reduces list ofPromises into Promise<List>. -
toList
@Contract(pure=true) public static <T> Promise<List<T>> toList(Stream<? extends Promise<? extends T>> promises) - See Also:
-
toList
@Contract(pure=true) public static <T> Promise<List<T>> toList(Iterable<? extends Promise<? extends T>> promises) - See Also:
-
toList
@Contract(pure=true) public static <T> Promise<List<T>> toList(Iterator<? extends Promise<? extends T>> promises) - See Also:
-
toArray
Returns an array of providedtypeand length 0 wrapped inPromise. -
toArray
@Contract(pure=true) public static <T> Promise<T[]> toArray(Class<T> type, Promise<? extends T> promise1) Returns an array withpromise1result. -
toArray
@Contract(pure=true) public static <T> Promise<T[]> toArray(Class<T> type, Promise<? extends T> promise1, Promise<? extends T> promise2) Returns an array withpromise1andpromise2results. -
toArray
@Contract(pure=true) @SafeVarargs public static <T> Promise<T[]> toArray(Class<T> type, Promise<? extends T>... promises) - See Also:
-
toArray
@Contract(pure=true) public static <T> Promise<T[]> toArray(Class<T> type, List<? extends Promise<? extends T>> promises) Reduces promises into Promise<Array> -
toArray
@Contract(pure=true) public static <T> Promise<T[]> toArray(Class<T> type, Stream<? extends Promise<? extends T>> promises) - See Also:
-
toArray
@Contract(pure=true) public static <T> Promise<T[]> toArray(Class<T> type, Iterable<? extends Promise<? extends T>> promises) - See Also:
-
toArray
@Contract(pure=true) public static <T> Promise<T[]> toArray(Class<T> type, Iterator<? extends Promise<? extends T>> promises) - See Also:
-
toTuple
-
toTuple
-
toTuple
-
toTuple
-
toTuple
@Contract(pure=true) public static <T1,T2, Promise<R> toTupleT3, T4, T5, R> (io.activej.common.tuple.TupleConstructor5<T1, T2, T3, T4, T5, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5) -
toTuple
@Contract(pure=true) public static <T1,T2, Promise<R> toTupleT3, T4, T5, T6, R> (io.activej.common.tuple.TupleConstructor6<T1, T2, T3, T4, T5, T6, R> constructor, Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5, Promise<? extends T6> promise6) -
toTuple
-
toTuple
-
toTuple
-
toTuple
-
toTuple
-
toTuple
@Contract(pure=true) public static <T1,T2, Promise<io.activej.common.tuple.Tuple6<T1,T3, T4, T5, T6> T2, toTupleT3, T4, T5, T6>> (Promise<? extends T1> promise1, Promise<? extends T2> promise2, Promise<? extends T3> promise3, Promise<? extends T4> promise4, Promise<? extends T5> promise5, Promise<? extends T6> promise6) -
mapTuple
@Contract(pure=true) public static <T,T1, AsyncFunction<T,R, R1> R> mapTuple(io.activej.common.tuple.TupleConstructor1<R1, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1) -
mapTuple
-
mapTuple
@Contract(pure=true) public static <T,T1, AsyncFunction<T,T2, T3, R, R1, R2, R3> R> mapTuple(io.activej.common.tuple.TupleConstructor3<R1, R2, R3, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3) -
mapTuple
@Contract(pure=true) public static <T,T1, AsyncFunction<T,T2, T3, T4, R, R1, R2, R3, R4> R> mapTuple(io.activej.common.tuple.TupleConstructor4<R1, R2, R3, R4, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3, Function<? super T, T4> getter4, Function<T4, Promise<R4>> fn4) -
mapTuple
@Contract(pure=true) public static <T,T1, AsyncFunction<T,T2, T3, T4, T5, R, R1, R2, R3, R4, R5> R> mapTuple(io.activej.common.tuple.TupleConstructor5<R1, R2, R3, R4, R5, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3, Function<? super T, T4> getter4, Function<T4, Promise<R4>> fn4, Function<? super T, T5> getter5, Function<T5, Promise<R5>> fn5) -
mapTuple
@Contract(pure=true) public static <T,T1, AsyncFunction<T,T2, T3, T4, T5, T6, R, R1, R2, R3, R4, R5, R6> R> mapTuple(io.activej.common.tuple.TupleConstructor6<R1, R2, R3, R4, R5, R6, R> constructor, Function<? super T, T1> getter1, Function<T1, Promise<R1>> fn1, Function<? super T, T2> getter2, Function<T2, Promise<R2>> fn2, Function<? super T, T3> getter3, Function<T3, Promise<R3>> fn3, Function<? super T, T4> getter4, Function<T4, Promise<R4>> fn4, Function<? super T, T5> getter5, Function<T5, Promise<R5>> fn5, Function<? super T, T6> getter6, Function<T6, Promise<R6>> fn6) -
sequence
Returns aCompleteNullPromise -
sequence
Executes anAsyncRunnable, returning aPromise<Void>as a mark for completion -
sequence
Executes bothAsyncRunnables consequently, returning aPromise<Void>as a mark for completion -
sequence
- See Also:
-
sequence
- See Also:
-
sequence
- See Also:
-
sequence
Calls everyPromisefrompromisesin sequence and discards their results.Returns aSettablePromisewithnullresult as a marker when all of thepromisesare completed.- Returns:
Promisethat completes when allpromisesare completed
-
first
Picks the firstPromisethat was completed without exception.- See Also:
-
first
-
first
-
first
-
first
@SafeVarargs public static <T> Promise<T> first(BiPredicate<? super T, ? super Exception> predicate, AsyncSupplier<? extends T>... promises) - See Also:
-
first
public static <T> Promise<T> first(BiPredicate<? super T, ? super Exception> predicate, Iterable<? extends AsyncSupplier<? extends T>> promises) - See Also:
-
first
public static <T> Promise<T> first(BiPredicate<? super T, ? super Exception> predicate, Stream<? extends AsyncSupplier<? extends T>> promises) - See Also:
-
first
public static <T> Promise<T> first(BiPredicate<? super T, ? super Exception> predicate, Iterator<? extends Promise<? extends T>> promises) - Parameters:
predicate- filters results, consumes result ofPromise- Returns:
- first completed result of
Promisethat satisfies predicate
-
repeat
Repeats the operations of providedAsyncSupplier<Boolean>infinitely, until one of thePromises completes exceptionally or supplier returns a promise offalse. -
loop
public static <T> Promise<T> loop(@Nullable T seed, Predicate<T> loopCondition, io.activej.common.function.FunctionEx<T, Promise<T>> next) Repeats providedFunctionExuntil can passPredicatetest. Resembles a simple Javafor()loop but with async capabilities.- Parameters:
seed- start valueloopCondition- a boolean function which checks if this loop can continuenext- a function applied to the seed, returnsPromise- Returns:
SettablePromisewithnullresult if it was completed successfully, otherwise returns aSettablePromisewith an exception. In both situations returnedPromiseis a marker of completion of the loop.
-
until
-
retry
-
retry
public static <T> Promise<T> retry(BiPredicate<? super T, Exception> breakCondition, AsyncSupplier<T> supplier) -
retry
-
retry
public static <T> Promise<T> retry(AsyncSupplier<T> supplier, BiPredicate<T, Exception> breakCondition, RetryPolicy<?> retryPolicy) -
asPromises
public static <T> Iterator<Promise<T>> asPromises(Iterator<? extends AsyncSupplier<? extends T>> tasks) -
asPromises
public static <T> Iterator<Promise<T>> asPromises(Stream<? extends AsyncSupplier<? extends T>> tasks) -
asPromises
public static <T> Iterator<Promise<T>> asPromises(Iterable<? extends AsyncSupplier<? extends T>> tasks) -
asPromises
-
reduce
public static <T,A, Promise<R> reduceR> (@Nullable A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, Collection<Promise<T>> promises) - See Also:
-
#reduce(A, BiConsumerEx, FunctionEx, Iterator)
-
reduce
public static <T,A, Promise<R> reduceR> (@Nullable A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, Stream<Promise<T>> promises) - See Also:
-
#reduce(A, BiConsumerEx, FunctionEx, Iterator)
-
reduce
public static <T,A, Promise<R> reduceR> (@Nullable A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, Iterator<Promise<T>> promises) Asynchronously reduceIteratorofPromise<T>s into aPromise<R>.To reduce promises a following arguments should be supplied an accumulator, a combiner, a finisher and an iterator of promises
Reduction principle is somewhat similar to the
Collector.of(Supplier, BiConsumer, BinaryOperator, Function, Collector.Characteristics...)If one of the
Promises completes exceptionally, a resulting promise will be completed exceptionally as well.- Type Parameters:
T- type of input elements for this operationA- type of accumulator of intermediate promise resultsR- the result type of the reduction- Parameters:
accumulator- a promise result accumulator that holds intermediate promise resultscombiner- a combiner consumer that defines how promise results should be accumulatedfinisher- a finisher function that maps an accumulator to a result valuepromises-IteratorofPromises- Returns:
- a
Promiseof the accumulated result of the reduction.
-
reduce
public static <T,A, Promise<R> reduceR> (Collector<T, A, R> collector, int maxCalls, Iterator<Promise<T>> promises) Asynchronously reduceIteratorofPromise<T>s into aPromise<R>with the help ofCollector.You can control the amount of concurrently running
Promises.If one of the
Promises completes exceptionally, a resulting promise will be completed exceptionally as well.This method is universal and allows implementing app-specific logic.
- Type Parameters:
T- type of input elements for this operationA- type of accumulator of intermediate promise resultsR- the result type of the reduction- Parameters:
collector- mutable reduction operation that accumulates input elements into a mutable result containermaxCalls- max number of concurrently runningPromisespromises-IterableofPromises- Returns:
- a
Promiseof the accumulated result of the reduction.
-
reduce
public static <T,A, Promise<R> reduceR> (@Nullable A accumulator, io.activej.common.function.BiConsumerEx<A, T> combiner, io.activej.common.function.FunctionEx<A, R> finisher, int maxCalls, Iterator<Promise<T>> promises) Asynchronously reduceIteratorofPromise<T>s into aPromise<R>.To reduce promises a following arguments should be supplied an accumulator, a combiner, a finisher and an iterator of promises
You can control the amount of concurrently running
Promises.Reduction principle is somewhat similar to the
Collector.of(Supplier, BiConsumer, BinaryOperator, Function, Collector.Characteristics...)If one of the
Promises completes exceptionally, a resulting promise will be completed exceptionally as well.- Type Parameters:
T- type of input elements for this operationA- type of accumulator of intermediate promise resultsR- the result type of the reduction- Parameters:
accumulator- a promise result accumulator that holds intermediate promise resultscombiner- a combiner consumer that defines how promise results should be accumulatedfinisher- a finisher function that maps an accumulator to a result valuemaxCalls- max number of concurrently runningPromisespromises-IteratorofPromises- Returns:
- a
Promiseof the accumulated result of the reduction.
-
coalesce
@Contract(pure=true) public static <T,A, AsyncFunction<T,R> R> coalesce(Supplier<A> argumentAccumulatorSupplier, BiConsumer<A, T> argumentAccumulatorFn, AsyncFunction<A, R> fn)
-