return a future which is completed upon connection close

@param reg

@return future completed upon termination of scheduling (disconnect)
777424
public IPromise scheduleSendLoop(ConnectionRegistry reg) {
        Promise promise = new Promise();
        sendJobs.add(new ScheduleEntry(reg, promise));
        synchronized (this) {
            if ( ! loopStarted ) {
                loopStarted = true;
                Actor.current().execute(this);
            }
        }
        return promise;
    }
1270124
public CompletableFuture<Void> closeAsync() {

        if (debugEnabled) {
            logger.debug("closeAsync()");
        }

        if (CLOSED.get(this) == ST_CLOSED) {
            logger.warn("Connection is already closed");
            return closeFuture;
        }

        if (CLOSED.compareAndSet(this, ST_OPEN, ST_CLOSED)) {

            active = false;
            CompletableFuture<Void> future = channelWriter.closeAsync();

            future.whenComplete((v, t) -> {

                closeEvents.fireEventClosed(this);
                closeEvents = new CloseEvents();

                if (t != null) {
                    closeFuture.completeExceptionally(t);
                } else {
                    closeFuture.complete(v);
                }
            });
        } else {
            logger.warn("Connection is already closed (concurrently)");
        }

        return closeFuture;
    }
447973
@SuppressWarnings("unchecked")
  public CompletableFuture<A> connect() {
    return registry.createPrimitive(name(), type())
        .thenApply(v -> (A) this);
  }
539733
protected Future<?> getFuture() {
	long stamp = lock.tryOptimisticRead();
	Future<?> future = this.future;
	if (!lock.validate(stamp)) { // Not valid so wait for read lock
	    stamp = lock.readLock();
	    try {
		future = this.future;
	    } finally {
		lock.unlockRead(stamp);
	    }
	}
	return future;
    }
992414
Future<ExtenderConfiguration> getExtensionConfiguration() {
        return new HAConfFuture<>(invokeSubserviceConfUpdates(),
                new HAConfFuture.ConfResultSupplier<ConsolidatedResult<ExtenderConfiguration>>() {
                    public ConsolidatedResult<ExtenderConfiguration> get() {
                        return lastConsolidatedConfiguration;
                    }
                });
    }
1103091
public CompletableFuture<Void> close() {
    for (OperationAttempt attempt : new ArrayList<>(attempts.values())) {
      attempt.fail(new ClosedSessionException("session closed"));
    }
    attempts.clear();
    return CompletableFuture.completedFuture(null);
  }
258418
private void expireSession(long index, long timestamp, ServerSessionContext session, CompletableFuture<Void> future, ThreadContext context) {
    if (!log.isOpen()) {
      context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
      return;
    }

    // If the session is already in an inactive state, complete the future exceptionally.
    if (!session.state().active()) {
      context.executor().execute(() -> future.completeExceptionally(new UnknownSessionException("inactive session: " + session.id())));
      return;
    }

    // Trigger scheduled callbacks in the state machine.
    executor.tick(index, timestamp);

    // Update the state machine context with the unregister entry's index. This ensures that events published
    // within the expire or close methods will be properly associated with the unregister entry's index.
    // All events published during expiration or closing of a session are linearizable to ensure that clients
    // receive related events before the expiration is completed.
    executor.init(index, Instant.ofEpochMilli(timestamp), ServerStateMachineContext.Type.COMMAND);

    // Expire the session and call state machine callbacks.
    session.expire(index);
    for (SessionListener listener : executor.context().sessions().listeners) {
      listener.expire(session);
      listener.close(session);
    }

    // Calculate the last completed index.
    long lastCompleted = calculateLastCompleted(index);

    // Once expiration callbacks have been completed, ensure that events published during the callbacks
    // are published in batch. The state machine context will generate an event future for all published events
    // to all sessions. If the event future is non-null, that indicates events are pending which were published
    // during the call to expire(). Wait for the events to be received by the client before completing the future.
    executor.commit();
    context.executor().execute(() -> {
      setLastCompleted(lastCompleted);
      future.complete(null);
    });
  }
271039
public Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals) {

        return query0(nameServerAddr, question, toArray(additionals, false), true, ch.newPromise(),
                     ch.eventLoop().<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>>newPromise());
    }
1335327
public static <T> T get(Future<T> future) {
    return get(future, 30, TimeUnit.SECONDS);
  }
1038895
function (reg){
 	ent=reg.split(":");
 	indeces=ent[1].split("-")
 	var reg = new SeqRegion(ent[0], indeces[0], indeces[1]);
 	return reg;
 }
558613
private CompletableFuture<Connection> connect() {
    // If the address selector has been reset then reset the connection.
    if (selector.state() == AddressSelector.State.RESET && connection != null) {
      if (connectFuture != null) {
        return connectFuture;
      }

      CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
      future.whenComplete((r, e) -> this.connectFuture = null);
      this.connectFuture = future;

      Connection oldConnection = this.connection;
      this.connection = null;
      oldConnection.close();
      connect(future);
      return future;
    }

    // If a connection was already established then use that connection.
    if (connection != null) {
      return CompletableFuture.completedFuture(connection);
    }

    // If a connection is currently being established then piggyback on the connect future.
    if (connectFuture != null) {
      return connectFuture;
    }

    // Create a new connect future and connect to the first server in the cluster.
    CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
    future.whenComplete((r, e) -> this.connectFuture = null);
    this.connectFuture = future;
    reset().connect(future);
    return future;
  }
915127
public static <T> T get(Future<T> future) throws ExecutionException {
        try {
            return future.get();
        } catch (InterruptedException e) {
            logger.log(Level.SEVERE, "Re-throwing InterruptedException as ExecutionException");
            throw new ExecutionException(e);
        }
    }
708802
@Override
    public Future<M> getDataFuture() {
        try {
            return FutureProcessor.completedFuture(getData());
        } catch (NotAvailableException ex) {
            CompletableFuture future = new CompletableFuture();
            future.completeExceptionally(ex);
            return future;
        }
    }
532837
public Router get(@NotNull final Pattern regex, @NotNull final Handler<YokeRequest> handler) {
        return get(regex, new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                handler.handle(request);
            }
        });
    }
642376
public <T> Future<T> submit(Runnable runnable, T result) {
        return mService.submit(runnable, result);
    }
655942
public <T> CompletableFuture<T> submit(Query<T> query) {
    State state = state();
    if (state == State.CLOSED || state == State.EXPIRED) {
      return Futures.exceptionalFuture(new ClosedSessionException("session closed"));
    }
    return submitter.submit(query);
  }
1012988
CompletableFuture<Void> close() {
    return closeClient()
        .exceptionally(v -> null)
        .thenCompose(v -> closeServer())
        .exceptionally(v -> null);
  }