mirror of
https://github.com/tommyskeff/futur4j.git
synced 2026-01-18 07:16:45 +00:00
promise util with propagate cancellation options
This commit is contained in:
@@ -12,7 +12,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class PromiseUtil {
|
||||
|
||||
@@ -30,42 +29,86 @@ public final class PromiseUtil {
|
||||
return pfac.unresolved();
|
||||
}
|
||||
|
||||
public static @NotNull <K, V> Promise<Map.Entry<K, V>> combine(boolean propagateCancel, @NotNull Promise<K> p1, @NotNull Promise<V> p2) {
|
||||
return pfac.combine(propagateCancel, p1, p2);
|
||||
}
|
||||
|
||||
public static @NotNull <K, V> Promise<Map.Entry<K, V>> combine(@NotNull Promise<K> p1, @NotNull Promise<V> p2) {
|
||||
return pfac.combine(p1, p2);
|
||||
}
|
||||
|
||||
public static @NotNull <K, V> Promise<Map<K, V>> combine(boolean propagateCancel, @NotNull Map<K, Promise<V>> promises, @Nullable BiConsumer<K, Throwable> exceptionHandler) {
|
||||
return pfac.combine(propagateCancel, promises, exceptionHandler);
|
||||
}
|
||||
|
||||
public static @NotNull <K, V> Promise<Map<K, V>> combine(@NotNull Map<K, Promise<V>> promises, @Nullable BiConsumer<K, Throwable> exceptionHandler) {
|
||||
return pfac.combine(promises, exceptionHandler);
|
||||
}
|
||||
|
||||
public static @NotNull <K, V> Promise<Map<K, V>> combine(boolean propagateCancel, @NotNull Map<K, Promise<V>> promises) {
|
||||
return pfac.combine(propagateCancel, promises);
|
||||
}
|
||||
|
||||
public static @NotNull <K, V> Promise<Map<K, V>> combine(@NotNull Map<K, Promise<V>> promises) {
|
||||
return pfac.combine(promises);
|
||||
}
|
||||
|
||||
public static @NotNull <V> Promise<List<V>> combine(@NotNull Iterable<Promise<V>> promises, @Nullable Consumer<Throwable> exceptionHandler) {
|
||||
public static @NotNull <V> Promise<List<V>> combine(boolean propagateCancel, @NotNull Iterable<Promise<V>> promises, @Nullable BiConsumer<Integer, Throwable> exceptionHandler) {
|
||||
return pfac.combine(propagateCancel, promises, exceptionHandler);
|
||||
}
|
||||
|
||||
public static @NotNull <V> Promise<List<V>> combine(@NotNull Iterable<Promise<V>> promises, @Nullable BiConsumer<Integer, Throwable> exceptionHandler) {
|
||||
return pfac.combine(promises, exceptionHandler);
|
||||
}
|
||||
|
||||
public static @NotNull <V> Promise<List<V>> combine(boolean propagateCancel, @NotNull Iterable<Promise<V>> promises) {
|
||||
return pfac.combine(propagateCancel, promises);
|
||||
}
|
||||
|
||||
public static @NotNull <V> Promise<List<V>> combine(@NotNull Iterable<Promise<V>> promises) {
|
||||
return pfac.combine(promises);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<List<PromiseCompletion<?>>> allSettled(boolean propagateCancel, @NotNull Iterable<Promise<?>> promiseIterable) {
|
||||
return pfac.allSettled(propagateCancel, promiseIterable);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<List<PromiseCompletion<?>>> allSettled(@NotNull Iterable<Promise<?>> promiseIterable) {
|
||||
return pfac.allSettled(promiseIterable);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<List<PromiseCompletion<?>>> allSettled(boolean propagateCancel, @NotNull Promise<?>... promiseArray) {
|
||||
return pfac.allSettled(propagateCancel, promiseArray);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<List<PromiseCompletion<?>>> allSettled(@NotNull Promise<?>... promiseArray) {
|
||||
return pfac.allSettled(promiseArray);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<Void> all(boolean propagateCancel, @NotNull Iterable<Promise<?>> promiseIterable) {
|
||||
return pfac.all(propagateCancel, promiseIterable);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<Void> all(@NotNull Iterable<Promise<?>> promiseIterable) {
|
||||
return pfac.all(promiseIterable);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<Void> all(boolean propagateCancel, @NotNull Promise<?>... promiseArray) {
|
||||
return pfac.all(propagateCancel, promiseArray);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<Void> all(@NotNull Promise<?>... promiseArray) {
|
||||
return pfac.all(promiseArray);
|
||||
}
|
||||
|
||||
public static <V> @NotNull Promise<V> race(@NotNull Iterable<Promise<V>> promises) {
|
||||
return pfac.race(promises);
|
||||
}
|
||||
|
||||
public static <V> @NotNull Promise<V> race(boolean cancelRaceLosers, @NotNull Iterable<Promise<V>> promises) {
|
||||
return pfac.race(cancelRaceLosers, promises);
|
||||
}
|
||||
|
||||
public static @NotNull <T> Promise<T> wrap(@NotNull CompletableFuture<T> future) {
|
||||
return pfac.wrap(future);
|
||||
}
|
||||
@@ -78,16 +121,12 @@ public final class PromiseUtil {
|
||||
return pfac.resolve(value);
|
||||
}
|
||||
|
||||
public static @NotNull <T> Promise<T> error(@NotNull Throwable error) {
|
||||
return pfac.error(error);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<Void> erase(@NotNull Promise<?> p) {
|
||||
return pfac.erase(p);
|
||||
}
|
||||
|
||||
public static @NotNull Promise<Void> start() {
|
||||
return pfac.start();
|
||||
}
|
||||
|
||||
public static @NotNull <T> Promise<T> error(@NotNull Throwable error) {
|
||||
return pfac.error(error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public final class StaticPromiseFactory extends AbstractPromiseFactory<ScheduledFuture<?>> {
|
||||
public final class StaticPromiseFactory extends AbstractPromiseFactory<Future<?>> {
|
||||
|
||||
public final static StaticPromiseFactory INSTANCE = new StaticPromiseFactory();
|
||||
private final static @NotNull SinglePoolExecutor EXECUTOR = SinglePoolExecutor.create(1);
|
||||
@@ -21,18 +21,18 @@ public final class StaticPromiseFactory extends AbstractPromiseFactory<Scheduled
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull <T> Promise<T> unresolved() {
|
||||
return new SimplePromise<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PromiseExecutor<ScheduledFuture<?>> getExecutor() {
|
||||
public @NotNull <T> Promise<T> unresolved() {
|
||||
return new SimplePromise<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PromiseExecutor<Future<?>> getExecutor() {
|
||||
return EXECUTOR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user