Creates a new {@link VertxCompletableFuture} using the current context. This method is used to switch between
Vert.x contexts.

@return the created {@link VertxCompletableFuture}
502342
public VertxCompletableFuture<T> withContext() {
    Context context = Objects.requireNonNull(Vertx.currentContext());
    return withContext(context);
  }
236130
public static <T> CompletableFuture<T> toCompletableFuture(Single<T> single) {
        return Java8FutureUtils.createCompletableFuture(RxJava2FutureUtils.createValueSource(single));
    }
112346
public Serializable createContext() {
        Map<Integer, Object[]> shadow = null;
        if ( this.reverse != null ) {
            shadow = new HashMap<Integer, Object[]>();
        }
        return new MVELAccumulatorContext( shadow );
    }
142317
private CompletableFuture<TableBucket> getNextBucket() {
        val fromBatch = getNextBucketFromExistingBatch();
        if (fromBatch != null) {
            return CompletableFuture.completedFuture(fromBatch);
        }

        val canContinue = new AtomicBoolean(true);
        return Futures.loop(canContinue::get, this::fetchNextTableBuckets, canContinue::set, this.executor)
                .thenApply(v -> getNextBucketFromExistingBatch());
    }
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;
  }
1032080
public Vertx getVertx() {
        if(vertx != null) {
            return vertx;
        }

        if(getComponent().getVertx() != null) {
            vertx = getComponent().getVertx();
        } else {
            vertx = Vertx.vertx();
        }
        return vertx;
    }
447973
@SuppressWarnings("unchecked")
  public CompletableFuture<A> connect() {
    return registry.createPrimitive(name(), type())
        .thenApply(v -> (A) this);
  }
53790
@Trivial // traced by caller
    static <U> CompletionStage<U> completedStage(U value, Executor executor) {
        if (JAVA8) {
            return new ManagedCompletionStage<U>(CompletableFuture.completedFuture(value), executor, null);
        } else {
            ManagedCompletableFuture<U> stage = new ManagedCompletionStage<U>(executor);
            stage.super_complete(value);
            return stage;
        }
    }
251030
public static final Promise resolve() {
		return new Promise(CompletableFuture.completedFuture(new Tree((Tree) null, null, null)));
	}
1085217
public static <T> ListenableFuture<T> createListenableFuture(ValueSourceFuture<T> valueSourceFuture) {
        if (valueSourceFuture instanceof ListenableFutureBackedValueSourceFuture) {
            return ((ListenableFutureBackedValueSourceFuture<T>) valueSourceFuture).getWrappedFuture();
        } else {
            return new ValueSourceFutureBackedListenableFuture<>(valueSourceFuture);
        }
    }
917987
public static <T> CompletableFuture<T> failedFuture(Throwable exception) {
        CompletableFuture<T> result = new CompletableFuture<>();
        result.completeExceptionally(exception);
        return result;
    }
1226901
public CompletableFuture<Void> shutdown() {
    if (!started)
      return Futures.exceptionalFuture(new IllegalStateException("context not open"));

    CompletableFuture<Void> future = new CompletableFuture<>();
    context.getThreadContext().executor().execute(() -> {
      started = false;
      if (clientServer != null) {
        clientServer.close().whenCompleteAsync((clientResult, clientError) -> {
          internalServer.close().whenCompleteAsync((internalResult, internalError) -> {
            if (internalError != null) {
              future.completeExceptionally(internalError);
            } else if (clientError != null) {
              future.completeExceptionally(clientError);
            } else {
              future.complete(null);
            }
          }, context.getThreadContext().executor());
        }, context.getThreadContext().executor());
      } else {
        internalServer.close().whenCompleteAsync((internalResult, internalError) -> {
          if (internalError != null) {
            future.completeExceptionally(internalError);
          } else {
            future.complete(null);
          }
        }, context.getThreadContext().executor());
      }

      context.transition(CopycatServer.State.INACTIVE);
    });

    return future.whenCompleteAsync((result, error) -> {
      if (clientTransport != serverTransport) {
        clientTransport.close();
      }
      serverTransport.close();
      context.close();
      started = false;
    });
  }
602356
@Override
    public CompletableFuture<Void> completeUpdateConfiguration(VersionedMetadata<StreamConfigurationRecord> existing) {
        StreamConfigurationRecord current = existing.getObject();
        Preconditions.checkNotNull(current);
        if (current.isUpdating()) {
            StreamConfigurationRecord newProperty = StreamConfigurationRecord.complete(scope, name, current.getStreamConfiguration());
            log.debug("Completing update configuration for stream {}/{}", scope, name);
            return Futures.toVoid(setConfigurationData(new VersionedMetadata<>(newProperty, existing.getVersion())));
        } else {
            // idempotent
            return CompletableFuture.completedFuture(null);
        }
    }
1201416
static <T> TableIterator<T> empty() {
        return new TableIterator<>(
                () -> CompletableFuture.completedFuture(null),
                ignored -> CompletableFuture.completedFuture(null),
                new ArrayDeque<>(),
                ForkJoinPool.commonPool());
    }
809813
public CompletableFuture<Void> compact() {
    ComposableFuture<Void> future = new ComposableFuture<>();
    threadContext.execute(() -> stateMachine.compact().whenComplete(future));
    return future;
  }
65790
public final ControlCompleted createNewControlCompleted() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewControlCompleted");
    ControlCompleted msg = null;
    try {
      msg = new ControlCompletedImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewControlCompleted");
    return msg;
  }
1049042
private static <V> ListenableFuture<V> closedChannelFuture() {
    SettableFuture<V> future = SettableFuture.create();
    future.setException(new ClosedChannelException());
    return future;
  }