Package com.landawn.abacus.util
Class Futures
java.lang.Object
com.landawn.abacus.util.Futures
- Since:
- 0.9
- Author:
- Haiyang Li
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ContinuableFuture<List<T>>
allOf
(Collection<? extends Future<? extends T>> cfs) Returns a new Future that is completed when all of the given Futures complete.static <T> ContinuableFuture<List<T>>
Returns a new Future that is completed when all of the given Futures complete.static <T> ContinuableFuture<T>
anyOf
(Collection<? extends Future<? extends T>> cfs) Returns a new Future that, when any of the given Futures complete normally.static <T> ContinuableFuture<T>
Returns a new Future that, when any of the given Futures complete normally.static <T,
R> ContinuableFuture<R> combine
(Collection<? extends Future<? extends T>> cfs, Throwables.Function<List<T>, ? extends R, ? extends Exception> action) static <T1,
T2> ContinuableFuture<Tuple.Tuple2<T1, T2>> static <T1,
T2, R> ContinuableFuture<R> combine
(Future<? extends T1> cf1, Future<? extends T2> cf2, Throwables.BiFunction<? super T1, ? super T2, ? extends R, ? extends Exception> action) static <T1,
T2, T3> ContinuableFuture<Tuple.Tuple3<T1, T2, T3>> static <T1,
T2, T3, R>
ContinuableFuture<R>combine
(Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Throwables.TriFunction<? super T1, ? super T2, ? super T3, ? extends R, ? extends Exception> action) static <T1,
T2, T3, T4>
ContinuableFuture<Tuple.Tuple4<T1,T2, T3, T4>> combine
(Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4) static <T1,
T2, T3, T4, T5>
ContinuableFuture<Tuple.Tuple5<T1,T2, T3, T4, T5>> combine
(Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4, Future<? extends T5> cf5) static <T1,
T2, T3, T4, T5, T6>
ContinuableFuture<Tuple.Tuple6<T1,T2, T3, T4, T5, T6>> combine
(Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4, Future<? extends T5> cf5, Future<? extends T6> cf6) static <T1,
T2, T3, T4, T5, T6, T7>
ContinuableFuture<Tuple.Tuple7<T1,T2, T3, T4, T5, T6, T7>> combine
(Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4, Future<? extends T5> cf5, Future<? extends T6> cf6, Future<? extends T7> cf7) static <T,
FC extends Collection<? extends Future<? extends T>>, R>
ContinuableFuture<R>compose
(FC cfs, Throwables.Function<? super FC, R, Exception> zipFunctionForGet) static <T,
FC extends Collection<? extends Future<? extends T>>, R>
ContinuableFuture<R>compose
(FC cfs, Throwables.Function<? super FC, R, Exception> zipFunctionForGet, Throwables.Function<? super Tuple.Tuple3<FC, Long, TimeUnit>, R, Exception> zipFunctionTimeoutGet) static <T1,
T2, R> ContinuableFuture<R> compose
(Future<T1> cf1, Future<T2> cf2, Throwables.BiFunction<? super Future<T1>, ? super Future<T2>, R, Exception> zipFunctionForGet) static <T1,
T2, R> ContinuableFuture<R> compose
(Future<T1> cf1, Future<T2> cf2, Throwables.BiFunction<? super Future<T1>, ? super Future<T2>, R, Exception> zipFunctionForGet, Throwables.Function<? super Tuple.Tuple4<Future<T1>, Future<T2>, Long, TimeUnit>, R, Exception> zipFunctionTimeoutGet) static <T1,
T2, T3, R>
ContinuableFuture<R>compose
(Future<T1> cf1, Future<T2> cf2, Future<T3> cf3, Throwables.TriFunction<? super Future<T1>, ? super Future<T2>, ? super Future<T3>, R, Exception> zipFunctionForGet) static <T1,
T2, T3, R>
ContinuableFuture<R>compose
(Future<T1> cf1, Future<T2> cf2, Future<T3> cf3, Throwables.TriFunction<? super Future<T1>, ? super Future<T2>, ? super Future<T3>, R, Exception> zipFunctionForGet, Throwables.Function<? super Tuple.Tuple5<Future<T1>, Future<T2>, Future<T3>, Long, TimeUnit>, R, Exception> zipFunctionTimeoutGet) static <T> ObjIterator<T>
iterate
(Collection<? extends Future<? extends T>> cfs) static <T> ObjIterator<T>
iterate
(Collection<? extends Future<? extends T>> cfs, long totalTimeoutForAll, TimeUnit unit) static <T> ObjIterator<T>
static <T> ObjIterator<Result<T,
Exception>> iteratte
(Collection<? extends Future<? extends T>> cfs) static <T> ObjIterator<Result<T,
Exception>> iteratte
(Collection<? extends Future<? extends T>> cfs, long totalTimeoutForAll, TimeUnit unit) static <T> ObjIterator<Result<T,
Exception>>
-
Method Details
-
compose
public static <T1,T2, ContinuableFuture<R> composeR> (Future<T1> cf1, Future<T2> cf2, Throwables.BiFunction<? super Future<T1>, ? super Future<T2>, R, Exception> zipFunctionForGet) - Type Parameters:
T1
-T2
-R
-- Parameters:
cf1
-cf2
-zipFunctionForGet
-- Returns:
-
compose
public static <T1,T2, ContinuableFuture<R> composeR> (Future<T1> cf1, Future<T2> cf2, Throwables.BiFunction<? super Future<T1>, ? super Future<T2>, R, Exception> zipFunctionForGet, Throwables.Function<? super Tuple.Tuple4<Future<T1>, Future<T2>, Long, TimeUnit>, R, Exception> zipFunctionTimeoutGet) - Type Parameters:
T1
-T2
-R
-- Parameters:
cf1
-cf2
-zipFunctionForGet
-zipFunctionTimeoutGet
-- Returns:
-
compose
public static <T1,T2, ContinuableFuture<R> composeT3, R> (Future<T1> cf1, Future<T2> cf2, Future<T3> cf3, Throwables.TriFunction<? super Future<T1>, ? super Future<T2>, ? super Future<T3>, R, Exception> zipFunctionForGet) - Type Parameters:
T1
-T2
-T3
-R
-- Parameters:
cf1
-cf2
-cf3
-zipFunctionForGet
-- Returns:
-
compose
public static <T1,T2, ContinuableFuture<R> composeT3, R> (Future<T1> cf1, Future<T2> cf2, Future<T3> cf3, Throwables.TriFunction<? super Future<T1>, ? super Future<T2>, ? super Future<T3>, R, Exception> zipFunctionForGet, Throwables.Function<? super Tuple.Tuple5<Future<T1>, Future<T2>, Future<T3>, Long, TimeUnit>, R, Exception> zipFunctionTimeoutGet) - Type Parameters:
T1
-T2
-T3
-R
-- Parameters:
cf1
-cf2
-cf3
-zipFunctionForGet
-zipFunctionTimeoutGet
-- Returns:
-
compose
public static <T,FC extends Collection<? extends Future<? extends T>>, ContinuableFuture<R> composeR> (FC cfs, Throwables.Function<? super FC, R, Exception> zipFunctionForGet) - Type Parameters:
T
-FC
-R
-- Parameters:
cfs
-zipFunctionForGet
-- Returns:
-
compose
public static <T,FC extends Collection<? extends Future<? extends T>>, ContinuableFuture<R> composeR> (FC cfs, Throwables.Function<? super FC, R, Exception> zipFunctionForGet, Throwables.Function<? super Tuple.Tuple3<FC, Long, TimeUnit>, R, Exception> zipFunctionTimeoutGet) - Type Parameters:
T
-FC
-R
-- Parameters:
cfs
-zipFunctionForGet
-zipFunctionTimeoutGet
-- Returns:
-
combine
public static <T1,T2> ContinuableFuture<Tuple.Tuple2<T1,T2>> combine(Future<? extends T1> cf1, Future<? extends T2> cf2) - Type Parameters:
T1
-T2
-- Parameters:
cf1
-cf2
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<Tuple.Tuple3<T1,T3> T2, combineT3>> (Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3) - Type Parameters:
T1
-T2
-T3
-- Parameters:
cf1
-cf2
-cf3
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<Tuple.Tuple4<T1,T3, T4> T2, combineT3, T4>> (Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4) - Type Parameters:
T1
-T2
-T3
-T4
-- Parameters:
cf1
-cf2
-cf3
-cf4
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<Tuple.Tuple5<T1,T3, T4, T5> T2, combineT3, T4, T5>> (Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4, Future<? extends T5> cf5) - Type Parameters:
T1
-T2
-T3
-T4
-T5
-- Parameters:
cf1
-cf2
-cf3
-cf4
-cf5
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<Tuple.Tuple6<T1,T3, T4, T5, T6> T2, combineT3, T4, T5, T6>> (Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4, Future<? extends T5> cf5, Future<? extends T6> cf6) - Type Parameters:
T1
-T2
-T3
-T4
-T5
-T6
-- Parameters:
cf1
-cf2
-cf3
-cf4
-cf5
-cf6
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<Tuple.Tuple7<T1,T3, T4, T5, T6, T7> T2, combineT3, T4, T5, T6, T7>> (Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Future<? extends T4> cf4, Future<? extends T5> cf5, Future<? extends T6> cf6, Future<? extends T7> cf7) - Type Parameters:
T1
-T2
-T3
-T4
-T5
-T6
-T7
-- Parameters:
cf1
-cf2
-cf3
-cf4
-cf5
-cf6
-cf7
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<R> combineR> (Future<? extends T1> cf1, Future<? extends T2> cf2, Throwables.BiFunction<? super T1, ? super T2, ? extends R, ? extends Exception> action) - Type Parameters:
T1
-T2
-R
-- Parameters:
cf1
-cf2
-action
-- Returns:
-
combine
public static <T1,T2, ContinuableFuture<R> combineT3, R> (Future<? extends T1> cf1, Future<? extends T2> cf2, Future<? extends T3> cf3, Throwables.TriFunction<? super T1, ? super T2, ? super T3, ? extends R, ? extends Exception> action) - Type Parameters:
T1
-T2
-T3
-R
-- Parameters:
cf1
-cf2
-cf3
-action
-- Returns:
-
combine
public static <T,R> ContinuableFuture<R> combine(Collection<? extends Future<? extends T>> cfs, Throwables.Function<List<T>, ? extends R, ? extends Exception> action) - Type Parameters:
T
-R
-- Parameters:
cfs
-action
-- Returns:
-
allOf
Returns a new Future that is completed when all of the given Futures complete. If any of the given Futures complete exceptionally, then the returned Future also does so.- Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
allOf
Returns a new Future that is completed when all of the given Futures complete. If any of the given Futures complete exceptionally, then the returned Future also does so.- Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
anyOf
Returns a new Future that, when any of the given Futures complete normally. If all of the given Futures complete exceptionally, then the returned Future also does so.- Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
anyOf
Returns a new Future that, when any of the given Futures complete normally. If all of the given Futures complete exceptionally, then the returned Future also does so.- Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
iterate
- Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
iterate
- Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
iterate
public static <T> ObjIterator<T> iterate(Collection<? extends Future<? extends T>> cfs, long totalTimeoutForAll, TimeUnit unit) - Type Parameters:
T
-- Parameters:
cfs
-totalTimeoutForAll
-unit
-- Returns:
-
iteratte
@SafeVarargs public static <T> ObjIterator<Result<T,Exception>> iteratte(Future<? extends T>... cfs) - Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
iteratte
public static <T> ObjIterator<Result<T,Exception>> iteratte(Collection<? extends Future<? extends T>> cfs) - Type Parameters:
T
-- Parameters:
cfs
-- Returns:
-
iteratte
public static <T> ObjIterator<Result<T,Exception>> iteratte(Collection<? extends Future<? extends T>> cfs, long totalTimeoutForAll, TimeUnit unit) - Type Parameters:
T
-- Parameters:
cfs
-totalTimeoutForAll
-unit
-- Returns:
-