Creates a {@link FutureCombiner} that processes the completed futures whether or not they're
successful.

@since 20.0
435950
public static <V> FutureCombiner<V> whenAllComplete(
      Iterable<? extends ListenableFuture<? extends V>> futures) {
    return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
  }
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()));
    }
189784
public void addExtraBuild(ModuleBuildFuture future) {
		if (extraBuilds == null) {
			extraBuilds = new LinkedList<ModuleBuildFuture>();
		}
		extraBuilds.add(future);
	}
1366100
public List<E> results() throws Exception {
        List<E> result = new ArrayList<E>(futures.size());
        for (ICompletableFuture<E> f : futures) {
            result.add(f.get());
        }
        return result;
    }
368440
public static <T> CompletableFuture<List<T>> collectFrom(Stream<T> stream, Executor executor) {
        requireNonNull(stream, "stream");
        requireNonNull(executor, "executor");
        final CompletableFuture<List<T>> future = new CompletableFuture<>();
        executor.execute(() -> {
            try {
                future.complete(stream.collect(toImmutableList()));
            } catch (Exception e) {
                future.completeExceptionally(e);
            }
        });
        return future;
    }
1111430
@Override
    public FutureAppendable performAppends(int timeout, TimeUnit unit) throws IOException, HttpErrorPage,
            TimeoutException {
        return this.futureBuilder.performAppends(timeout, unit);
    }
790301
private void processResult(Executor executor) {
        // Process the result, one entry at a time, until one of the stopping conditions occurs.
        AtomicBoolean shouldContinue = new AtomicBoolean(true);
        Futures
                .loop(
                        () -> !this.closed.get() && shouldContinue.get(),
                        () -> {
                            CompletableFuture<ReadResultEntry> resultEntryFuture = fetchNextEntry();
                            shouldContinue.set(resultEntryFuture != null);
                            return resultEntryFuture != null ? resultEntryFuture : CompletableFuture.completedFuture(null);
                        },
                        resultEntry -> {
                            if (resultEntry != null) {
                                shouldContinue.set(this.entryHandler.processEntry(resultEntry));
                            }
                        },
                        executor)
                .whenComplete((r, ex) -> close(ex)); // Make sure always close the result processor when done (with our without failures).
    }
953890
@Override
    protected <T> CompletableFuture<T> doExecute(Command<T> command) throws Exception {
        final CompletableFuture<T> future = new CompletableFuture<>();
        executor.execute(() -> {
            try {
                future.complete(blockingExecute(command));
            } catch (Throwable t) {
                future.completeExceptionally(t);
            }
        });
        return future;
    }
238954
public static CompletableFuture<Void> from(ChannelFuture future) {

        LettuceAssert.notNull(future, "ChannelFuture must not be null");

        CompletableFuture<Void> result = new CompletableFuture<>();
        adapt(future, result);

        return result;
    }
1269465
@SuppressWarnings("unchecked")
    public CompletableFuture<Void> close() {

        this.closed = true;

        List<CompletableFuture<Void>> futures = new ArrayList<>();

        forEach((connectionKey, closeable) -> {

            futures.add(closeable.closeAsync());
            connections.remove(connectionKey);
        });

        return Futures.allOf(futures);
    }
1354117
public static <A> Will<A> forFuture(Future<A> future) {
        return new Of<A>(JdkFutureAdapters.listenInPoolThread(future));
    }
1219224
public <T> T resolveFuture(final Future<T> future) throws RuntimeException
	{
		return resolveFuture(future, true);
	}
415330
private Future<M> sync() {
        logger.debug("Synchronization of Remote[" + this + "] triggered...");
        try {
            validateInitialization();
            try {
                SyncTaskCallable syncCallable = new SyncTaskCallable();

                final Future<M> currentSyncTask = GlobalCachedExecutorService.submit(syncCallable);
                syncCallable.setRelatedFuture(currentSyncTask);
                return currentSyncTask;
            } catch (java.util.concurrent.RejectedExecutionException | NullPointerException ex) {
                throw new CouldNotPerformException("Could not request the current status.", ex);
            }
        } catch (CouldNotPerformException ex) {
            return FutureProcessor.canceledFuture(ex);
        }
    }
124282
protected <T extends OperationResponse> void completeOperation(ServerStateMachine.Result result, OperationResponse.Builder<?, T> builder, Throwable error, CompletableFuture<T> future) {
    if (isOpen()) {
      if (result != null) {
        builder.withIndex(result.index);
        builder.withEventIndex(result.eventIndex);
        if (result.result instanceof Exception) {
          error = (Exception) result.result;
        }
      }

      if (error == null) {
        future.complete(builder.withStatus(Response.Status.OK)
          .withResult(result != null ? result.result : null)
          .build());
      } else if (error instanceof CompletionException && error.getCause() instanceof CopycatException) {
        future.complete(builder.withStatus(Response.Status.ERROR)
          .withError(((CopycatException) error.getCause()).getType())
          .build());
      } else if (error instanceof CopycatException) {
        future.complete(builder.withStatus(Response.Status.ERROR)
          .withError(((CopycatException) error).getType())
          .build());
      } else {
        LOGGER.warn("An unexpected error occurred: {}", error);
        future.complete(builder.withStatus(Response.Status.ERROR)
          .withError(CopycatError.Type.INTERNAL_ERROR)
          .build());
      }
    }
  }
873169
def _add_future(cls, future):
    
    if cls._local._activated:
      cls._local._in_order_futures.add(future)
263744
private <T> CompletableFuture<T> executeOnTransientConnection(
      Address address,
      Function<ClientConnection, CompletableFuture<T>> callback,
      Executor executor) {
    CompletableFuture<T> future = new CompletableFuture<>();
    if (address.equals(returnAddress)) {
      callback.apply(localConnection).whenComplete((result, error) -> {
        if (error == null) {
          executor.execute(() -> future.complete(result));
        } else {
          executor.execute(() -> future.completeExceptionally(error));
        }
      });
      return future;
    }

    openChannel(address).whenComplete((channel, channelError) -> {
      if (channelError == null) {
        callback.apply(getOrCreateClientConnection(channel)).whenComplete((result, sendError) -> {
          if (sendError == null) {
            executor.execute(() -> future.complete(result));
          } else {
            executor.execute(() -> future.completeExceptionally(sendError));
          }
          channel.close();
        });
      } else {
        executor.execute(() -> future.completeExceptionally(channelError));
      }
    });
    return future;
  }
397470
public static <T> CompletableFuture<T> completedFuture(T result) {
    CompletableFuture<T> future = new AtomixFuture<>();
    future.complete(result);
    return future;
  }