FUTURE add to interface
175041
public Object callFunctionWithoutNamedValues(PageContext pc, Object coll, Collection.Key key, Object[] args, boolean noNull, Object defaultValue) {
	// MUST make an independent impl for performance reasons
	try {
	    if (!noNull || NullSupportHelper.full(pc)) return callFunctionWithoutNamedValues(pc, coll, key, args);
	    Object obj = callFunctionWithoutNamedValues(pc, coll, key, args);
	    return obj == null ? defaultValue : obj;

	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	    return defaultValue;
	}

    }
910135
async def wait_change(self):
        
        future = asyncio.Future(loop=self.loop)
        self._change_futures.add(future)
        future.add_done_callback(self._change_futures.discard)
        await future
301563
function populateApiFromInterface(api, iface) {
  Object.keys(iface).forEach(function (key) {
    api.add(key, iface[key]);
  });
}
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;
  }
1068810
boolean addImplementedInterface(JSTypeExpression interfaceName) {
    lazyInitInfo();
    if (info.implementedInterfaces == null) {
      info.implementedInterfaces = new ArrayList<>(2);
    }
    if (info.implementedInterfaces.contains(interfaceName)) {
      return false;
    }
    info.implementedInterfaces.add(interfaceName);
    return true;
  }
838914
private void connect(int attempt, CompletableFuture<SessionClient> future) {
    if (attempt > MAX_ATTEMPTS) {
      future.completeExceptionally(new PrimitiveException.Unavailable());
      return;
    }

    primaryElection.getTerm().whenCompleteAsync((term, error) -> {
      if (error == null) {
        if (term.primary() == null) {
          future.completeExceptionally(new PrimitiveException.Unavailable());
        } else {
          this.term = term;
          protocol.registerEventListener(sessionId, this::handleEvent, threadContext);
          future.complete(this);
        }
      } else {
        Throwable cause = Throwables.getRootCause(error);
        if (cause instanceof PrimitiveException.Unavailable || cause instanceof TimeoutException) {
          threadContext.schedule(Duration.ofMillis(RETRY_DELAY), () -> connect(attempt + 1, future));
        } else {
          future.completeExceptionally(new PrimitiveException.Unavailable());
        }
      }
    }, threadContext);
  }
232195
CompletableFuture<Void> connect(LocalConnection connection) {
    LocalConnection localConnection = new LocalConnection(listener.context, connections);
    connections.add(localConnection);
    connection.connect(localConnection);
    localConnection.connect(connection);
    return CompletableFuture.runAsync(() -> listener.listener.accept(localConnection), listener.context.executor());
  }
647679
public void registerOperation(final ListenableFuture<?> future) {
    count.incrementAndGet();
    Futures.addCallback(future, new FutureCallback<Object>() {
      @Override
      public void onSuccess(Object result) {
        onOperationCompletion();
      }

      @Override
      public void onFailure(Throwable t) {
        onOperationCompletion();
      }
    }, MoreExecutors.directExecutor());
  }
88685
private void openProxy(CompletableFuture<SessionClient> future) {
    log.debug("Opening proxy session");
    proxyFactory.get().thenCompose(proxy -> proxy.connect()).whenComplete((proxy, error) -> {
      if (error == null) {
        synchronized (this) {
          this.log = ContextualLoggerFactory.getLogger(getClass(), LoggerContext.builder(SessionClient.class)
              .addValue(proxy.sessionId())
              .add("type", proxy.type())
              .add("name", proxy.name())
              .build());
          this.session = proxy;
          proxy.addStateChangeListener(this::onStateChange);
          eventListeners.entries().forEach(entry -> proxy.addEventListener(entry.getKey(), entry.getValue()));
          onStateChange(PrimitiveState.CONNECTED);
        }
        future.complete(this);
      } else {
        recoverTask = context.schedule(Duration.ofSeconds(1), () -> openProxy(future));
      }
    });
  }
1101966
private CompletableFuture<Void> listen() {
    CompletableFuture<Void> future = new CompletableFuture<>();
    context.getThreadContext().executor().execute(() -> {
      internalServer.listen(cluster().member().serverAddress(), context::connectServer).whenComplete((internalResult, internalError) -> {
        if (internalError == null) {
          // If the client address is different than the server address, start a separate client server.
          if (clientServer != null) {
            clientServer.listen(cluster().member().clientAddress(), context::connectClient).whenComplete((clientResult, clientError) -> {
              started = true;
              future.complete(null);
            });
          } else {
            started = true;
            future.complete(null);
          }
        } else {
          future.completeExceptionally(internalError);
        }
      });
    });

    return future;
  }
834311
public <T> Future<T> submit(Callable<T> callable) {
        return executorService.submit(callable);
    }
125098
def add_callbacks(self, future, callback, errback):
        
        assert future is not None
        if callback is None:
            assert errback is not None
            future.addErrback(errback)
        else:
            # Twisted allows errback to be None here
            future.addCallbacks(callback, errback)
        return future
221758
@Override
    public Future<Message> add(StaticBuffer content) {
        return add(content,manager.defaultWritePartitionIds[random.nextInt(manager.defaultWritePartitionIds.length)]);
    }
524860
private CompletableFuture<Void> bind(Bootstrap bootstrap) {
    CompletableFuture<Void> future = new CompletableFuture<>();
    int port = config.getPort() != null ? config.getPort() : address.port();
    if (config.getInterfaces().isEmpty()) {
      bind(bootstrap, Lists.newArrayList("0.0.0.0").iterator(), port, future);
    } else {
      bind(bootstrap, config.getInterfaces().iterator(), port, future);
    }
    return future;
  }
977963
private <T extends Request, U> void sendRequest(T request, BiFunction<Request, Connection, CompletableFuture<U>> sender, CompletableFuture<U> future) {
    if (open) {
      connect().whenComplete((c, e) -> sendRequest(request, sender, c, e, 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);
        }
    }
421860
@Override
    public <R> Future<R> map(final Function<? super T, ? extends R> fn) {
        return new Future<R>(
                              future.thenApply(fn));
    }