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.

@param cfs
@return
437028
public static <T> ContinuableFuture<List<T>> allOf(final Collection<? extends Future<? extends T>> cfs) {
        return allOf2(cfs);
    }
148236
public <N> CompletableFutureQueue<T, N> thenCombineAsync(Function<R, N> nextTransformation) {
    final Function<T, CompletableFuture<N>> f = this.resultFunction
        .andThen(before -> before.thenComposeAsync(v -> supplyAsync(() -> nextTransformation.apply(v))));
    return new CompletableFutureQueue<>(f);
  }
314561
@Override
    public <R> Future<R> flatMap(final Function<? super T, ? extends MonadicValue<? extends R>> mapper) {
        return Future.<R>of(future.<R>thenCompose(t -> (CompletionStage<R>) Future.fromMonadicValue(mapper.apply(t)).getFuture()));
    }
969061
@Override
    public <T> Future<T> unit(final T unit) {
        return new Future<T>(
                              CompletableFuture.completedFuture(unit));
    }
928072
public CompletableFuture<Void> open() {
    CompletableFuture<Void> future = new CompletableFuture<>();
    context.executor().execute(() -> register(new RegisterAttempt(1, future)));
    return future;
  }
60647
public CompletableFuture<Void> snapshot() {
    return Futures.allOf(config.getMembers().stream()
        .map(MemberId::from)
        .map(id -> communicationService.send(snapshotSubject, null, id, SNAPSHOT_TIMEOUT))
        .collect(Collectors.toList()))
        .thenApply(v -> null);
  }
1291081
protected CompletableFuture<ExecutionResult> postExecuteAsync(ExecutionResult result, Scheduler scheduler,
      FailsafeFuture<Object> future) {
    if (isFailure(result)) {
      result = result.with(false, false);
      return onFailureAsync(result, scheduler, future).whenComplete((postResult, error) -> {
        callFailureListener(postResult);
      });
    } else {
      result = result.with(true, true);
      onSuccess(result);
      callSuccessListener(result);
      return CompletableFuture.completedFuture(result);
    }
  }
1174013
private <T> T complete(CompletableFuture<T> future, int acquirePermits) {
    AtomicBoolean needRelease = new AtomicBoolean(false);
    try {
      return future.thenApply(value -> {
        if (needRelease.get()) {
          if (acquirePermits > 0) {
            asyncSemaphore.release(acquirePermits);
          }
        }
        return value;
      }).get(timeout.toMillis(), TimeUnit.MILLISECONDS);
    } catch (InterruptedException | PrimitiveException.Interrupted e) {
      needRelease.set(acquirePermits > 0);
      Thread.currentThread().interrupt();
      throw new PrimitiveException.Interrupted();
    } catch (TimeoutException | PrimitiveException.Timeout e) {
      needRelease.set(acquirePermits > 0);
      throw new PrimitiveException.Timeout();
    } catch (ExecutionException e) {
      needRelease.set(acquirePermits > 0);
      Throwable cause = Throwables.getRootCause(e);
      if (cause instanceof PrimitiveException) {
        throw (PrimitiveException) cause;
      } else {
        throw new PrimitiveException(cause);
      }
    }
  }
304243
public CompletableFuture<Void> snapshot() {
    RaftPartitionServer server = this.server;
    if (server != null) {
      return server.snapshot();
    }
    return CompletableFuture.completedFuture(null);
  }
361291
static <E> List<E> getListFromFutures(List<Future<E>> futures) {
		List<E> list = new ArrayList<E>();
		for (Future<E> f : futures) {
			// TODO when added to ConcurrencyTools, log completions and exceptions instead of printing stack traces
			try {
				list.add(f.get());
			} catch (InterruptedException e) {
				logger.error("Interrupted Exception: ", e);
			} catch (ExecutionException e) {
				logger.error("Execution Exception: ", e);
			}
		}
		return list;
	}
903555
protected CompletableFuture<ExecutionResult> onFailureAsync(ExecutionResult result, Scheduler scheduler,
      FailsafeFuture<Object> future) {
    return CompletableFuture.completedFuture(onFailure(result));
  }
207120
@Override
  public <U> VertxCompletableFuture<U> thenApply(Function<? super T, ? extends U> fn) {
    return new VertxCompletableFuture<>(context, super.thenApply(fn));
  }
251030
public static final Promise resolve() {
		return new Promise(CompletableFuture.completedFuture(new Tree((Tree) null, null, null)));
	}
450084
static <T> RedisFuture<T> lastOfAsync(Map<?, ? extends CompletionStage<T>> executions) {

        return new PipelinedRedisFuture<>(executions, objectPipelinedRedisFuture -> {
            // make sure, that all futures are executed before returning the result.
                T result = null;
                for (CompletionStage<T> future : executions.values()) {
                    result = execute(() -> future.toCompletableFuture().get());
                }
                return result;
            });
    }
1272506
public static <T> AtomixFuture<T> wrap(CompletableFuture<T> future) {
    AtomixFuture<T> newFuture = new AtomixFuture<>();
    future.whenComplete((result, error) -> {
      if (error == null) {
        newFuture.complete(result);
      } else {
        newFuture.completeExceptionally(error);
      }
    });
    return newFuture;
  }
426022
public static <T> Future<T> of(final Supplier<T> s) {
        return Future.of(CompletableFuture.supplyAsync(s));
    }
1354117
public static <A> Will<A> forFuture(Future<A> future) {
        return new Of<A>(JdkFutureAdapters.listenInPoolThread(future));
    }