This method allows clients to poll the Future object and only get results
once the async method has finished (i.e. either with good results or an
exception).
16213
@Override
    public boolean isDone() {

        //F743-609CodRev - read volatile variable only once
        boolean done = ivDone;
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "isDone: " + done + " Future object: " + this);
        }

        return (done);
    }
44674
private CompletableFuture<Snapshot> takeSnapshots() {
    ComposableFuture<Snapshot> future = new ComposableFuture<>();
    stateContext.execute(() -> {
      try {
        future.complete(snapshot());
      } catch (Exception e) {
        future.completeExceptionally(e);
      }
    });
    return future;
  }
1014718
@Override
    public java.util.concurrent.Future<DescribeInstanceStatusResult> describeInstanceStatusAsync(
            com.amazonaws.handlers.AsyncHandler<DescribeInstanceStatusRequest, DescribeInstanceStatusResult> asyncHandler) {

        return describeInstanceStatusAsync(new DescribeInstanceStatusRequest(), asyncHandler);
    }
503045
private void complete(T result, Throwable error) {
    synchronized (orderedFutures) {
      this.result = result;
      this.error = error;
      this.complete = true;
      if (error == null) {
        for (CompletableFuture<T> future : orderedFutures) {
          future.complete(result);
        }
      } else {
        for (CompletableFuture<T> future : orderedFutures) {
          future.completeExceptionally(error);
        }
      }
      orderedFutures.clear();
    }
  }
347305
def done(self):
        """"""
        # Flush the current future in the local buffer (potential deadlock
        # otherwise)
        try:
            scoop._control.execQueue.remove(self)
            scoop._control.execQueue.socket.sendFuture(self)
        except ValueError as e:
            # Future was not in the local queue, everything is fine
            pass
        # Process buffers
        scoop._control.execQueue.updateQueue()
        return self._ended()
118217
public static <T> Future<T> ofResult(final T result) {
        return Future.of(CompletableFuture.completedFuture(result));
    }
490059
public ResultValue awaitResult(long maxWait, TimeUnit timeUnit) throws Exception
    {
        if (!await(maxWait, timeUnit))
        {
            throw new TimeoutException();
        }
        return getResultValue();
    }
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);
    }
  }
1051598
@Restricted(NoExternalUse.class)
    public synchronized final void maybeComplete() {
        assert this.executor != null;
        if (result != null) {
            executor.completedAsynchronous(result != NULL ? result : null);
            result = null;
        }
    }
1331449
def _endReq(self, key, result=None, success=True):
        
        future = self._futures.pop(key, None)
        self._reqId2Contract.pop(key, None)
        if future:
            if result is None:
                result = self._results.pop(key, [])
            if not future.done():
                if success:
                    future.set_result(result)
                else:
                    future.set_exception(result)
507239
def _return_result(self, done):
        
        chain_future(done, self._running_future)

        self.current_future = done
        self.current_index = self._unfinished.pop(done)
770207
protected <V> V awaitResult(ListenableFuture<V> future) {
    return awaitResult(future, timeout, TimeUnit.MILLISECONDS);
  }
850060
public ListenableFuture<T> fetchAsync(final TwilioRestClient client) {
        return Twilio.getExecutorService().submit(new Callable<T>() {
            public T call() {
                return fetch(client);
            }
        });
    }
465986
public Future<T> executeAsync() {

        return client.submit(new Callable<T>() {

            @Override
            public T call() throws Exception {
                return execute();
            }
        });
    }
770884
def get_results(self):
        '''
        
        '''
        self._event.wait()
        if self._exception is not None:
            #
            # Well... rethrownig the exception caught in execute
            # but on the caller thread
            #
            raise self._exception  # pylint: disable=E0702
        return self._result
238876
@Override
    public final void complete(Object res, Object error) {
        this.result = res;
        Object prevErr = this.error;
        this.error = error;
        while( !lock.compareAndSet(false,true) ) {}
        try {
            if (hadResult) {
                if ( prevErr instanceof Timeout ) {
                    this.error = prevErr;
                    lock.set(false);
                    return;
                }
                lock.set(false);
                throw new RuntimeException("Double result received on future prevErr:" + prevErr +" (res,err) "+res+","+error );
            }
            hadResult = true;
            if (resultReceiver != null) {
                if (hasFired) {
                    lock.set(false);
                    throw new RuntimeException("Double fire on callback");
                }
                hasFired = true;
                lock.set(false);
                resultReceiver.complete(result, error);
                resultReceiver = null;
                while (!lock.compareAndSet(false, true)) {
                }
                if (nextFuture != null) {
                    lock.set(false);
                    nextFuture.complete(result, error);
                }
                return;
            }
        } finally {
            lock.set(false);
        }
    }
239628
def sendResult(self, future):
        """"""
        future = copy.copy(future)

        # Remove the (now) extraneous elements from future class
        future.callable = future.args = future.kargs = future.greenlet = None

        if not future.sendResultBack:
            # Don't reply back the result if it isn't asked
            future.resultValue = None

        self._sendReply(
            future.id.worker,
            pickle.dumps(
                future,
                pickle.HIGHEST_PROTOCOL,
            ),
        )