private CompletionConjunctFuture(Collection<? extends CompletableFuture<?>> futuresToComplete) { numFuturesTotal = futuresToComplete.size(); futuresCompleted = 0; globalThrowable = null; if (futuresToComplete.isEmpty()) { complete(null); } else { for (CompletableFuture<?> completableFuture : futuresToComplete) { completableFuture.whenComplete(this::completeFuture); } } }
private void completeFuture(Object ignored, Throwable throwable) { synchronized (lock) { futuresCompleted++; if (throwable != null) { globalThrowable = ExceptionUtils.firstOrSuppressed(throwable, globalThrowable); } if (futuresCompleted == numFuturesTotal) { if (globalThrowable != null) { completeExceptionally(globalThrowable); } else { complete(null); } } } }
private void completeFuture(Object ignored, Throwable throwable) { synchronized (lock) { futuresCompleted++; if (throwable != null) { globalThrowable = ExceptionUtils.firstOrSuppressed(throwable, globalThrowable); } if (futuresCompleted == numFuturesTotal) { if (globalThrowable != null) { completeExceptionally(globalThrowable); } else { complete(null); } } } }
private void completeFuture(Object ignored, Throwable throwable) { synchronized (lock) { futuresCompleted++; if (throwable != null) { globalThrowable = ExceptionUtils.firstOrSuppressed(throwable, globalThrowable); } if (futuresCompleted == numFuturesTotal) { if (globalThrowable != null) { completeExceptionally(globalThrowable); } else { complete(null); } } } }
/** * Creates a {@link ConjunctFuture} which is only completed after all given futures have completed. * Unlike {@link FutureUtils#waitForAll(Collection)}, the resulting future won't be completed directly * if one of the given futures is completed exceptionally. Instead, all occurring exception will be * collected and combined to a single exception. If at least on exception occurs, then the resulting * future will be completed exceptionally. * * @param futuresToComplete futures to complete * @return Future which is completed after all given futures have been completed. */ public static ConjunctFuture<Void> completeAll(Collection<? extends CompletableFuture<?>> futuresToComplete) { return new CompletionConjunctFuture(futuresToComplete); }
/** * Creates a {@link ConjunctFuture} which is only completed after all given futures have completed. * Unlike {@link FutureUtils#waitForAll(Collection)}, the resulting future won't be completed directly * if one of the given futures is completed exceptionally. Instead, all occurring exception will be * collected and combined to a single exception. If at least on exception occurs, then the resulting * future will be completed exceptionally. * * @param futuresToComplete futures to complete * @return Future which is completed after all given futures have been completed. */ public static ConjunctFuture<Void> completeAll(Collection<? extends CompletableFuture<?>> futuresToComplete) { return new CompletionConjunctFuture(futuresToComplete); }
/** * Creates a {@link ConjunctFuture} which is only completed after all given futures have completed. * Unlike {@link FutureUtils#waitForAll(Collection)}, the resulting future won't be completed directly * if one of the given futures is completed exceptionally. Instead, all occurring exception will be * collected and combined to a single exception. If at least on exception occurs, then the resulting * future will be completed exceptionally. * * @param futuresToComplete futures to complete * @return Future which is completed after all given futures have been completed. */ public static ConjunctFuture<Void> completeAll(Collection<? extends CompletableFuture<?>> futuresToComplete) { return new CompletionConjunctFuture(futuresToComplete); }
private CompletionConjunctFuture(Collection<? extends CompletableFuture<?>> futuresToComplete) { this.futuresToComplete = checkNotNull(futuresToComplete); numFuturesTotal = futuresToComplete.size(); futuresCompleted = 0; globalThrowable = null; if (futuresToComplete.isEmpty()) { complete(null); } else { for (CompletableFuture<?> completableFuture : futuresToComplete) { completableFuture.whenComplete(this::completeFuture); } } }
private CompletionConjunctFuture(Collection<? extends CompletableFuture<?>> futuresToComplete) { numFuturesTotal = futuresToComplete.size(); futuresCompleted = 0; globalThrowable = null; if (futuresToComplete.isEmpty()) { complete(null); } else { for (CompletableFuture<?> completableFuture : futuresToComplete) { completableFuture.whenComplete(this::completeFuture); } } }