Returns raw result after waiting, or null if interrupted, or
throws TimeoutException on timeout.
19832
private Object timedGet(long nanos) throws TimeoutException {
        if (Thread.interrupted())
            return null;
        if (nanos > 0L) {
            long d = System.nanoTime() + nanos;
            long deadline = (d == 0L) ? 1L : d; // avoid 0
            Signaller q = null;
            boolean queued = false;
            Object r;
            while ((r = result) == null) { // similar to untimed, without spins
                if (q == null)
                    q = new Signaller(true, nanos, deadline);
                else if (!queued)
                    queued = tryPushStack(q);
                else if (q.nanos <= 0L)
                    break;
                else {
                    try {
                        ForkJoinPool.managedBlock(q);
                    } catch (InterruptedException ie) {
                        q.interrupted = true;
                    }
                    if (q.interrupted)
                        break;
                }
            }
            if (q != null)
                q.thread = null;
            if (r != null)
                postComplete();
            else
                cleanStack();
            if (r != null || (q != null && q.interrupted))
                return r;
        }
        throw new TimeoutException();
    }
216517
public void waitDone() throws ResponseTimeoutException,
            InvalidResponseException {
        lock.lock();
        try {
            if (!isDoneResponse()) {
                try {
                    condition.await(timeout, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    throw new RuntimeException("Interrupted");
                }
            }
            
            if (illegalResponseException != null) {
                throw illegalResponseException;
            }
            
            if (!isDoneResponse()) {
                throw new ResponseTimeoutException("No response after " + timeout
                        + " millis");
            }
        } finally {
            lock.unlock();
        }
    }
935206
function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }
643008
def get(self, timeout=None):
        
        if not self.wait(timeout):
            raise TimeoutError("Result not available within %fs" % timeout)
        if self._success:
            return self._data
        raise self._data[0]
314896
@Override
    public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
        // when get returns without an exception the synchronisation is complete
        // and else the exception will be thrown
        if (isInitialized()) {
            synchronisationFuture.get(timeout, unit);
        }
        return internalFuture.get(timeout, unit);
    }
921669
public void get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
        sync.innerGet(unit.toNanos(timeout));
    }
1306136
public T get() throws InterruptedException {
    if (!valueReady.await((long) (timeout * 1000), TimeUnit.MILLISECONDS)) {
      String msg = String.format("BlockingVariable.get() timed out after %1.2f seconds", timeout);
      throw new SpockTimeoutError(timeout, msg);
    }
    return value;
  }
919434
@Override
    public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
        V v = super.get(timeout, unit);
        this.mergeWorkerTracyTheadContext();
        return v;
    }
327341
def result(self):
    
    self.wait()
    if self._fatal_error:
      raise self._fatal_error
    return self._result
157103
def _wait_for_results(self):
        
        while True:
            get_timeout = self._next_timeout()
            try:
                msgtype, value = self.queue.get(timeout=get_timeout)
            except QueueEmpty:
                raise dbt.exceptions.RPCTimeoutException(self.timeout)

            if msgtype == QueueMessageType.Log:
                self.logs.append(value)
            elif msgtype in QueueMessageType.terminating():
                return msgtype, value
            else:
                raise dbt.exceptions.InternalException(
                    'Got invalid queue message type {}'.format(msgtype)
                )
140682
def _get_timeout(self, timeout):
        '''
        
        '''
        if timeout is None:
            return self.opts['timeout']
        if isinstance(timeout, int):
            return timeout
        if isinstance(timeout, six.string_types):
            try:
                return int(timeout)
            except ValueError:
                return self.opts['timeout']
        # Looks like the timeout is invalid, use config
        return self.opts['timeout']
294132
def get(self, timeout=None):
        """"""
        if timeout:
            try:
                result = self._queue.get(True, timeout)
            except multiprocessing.Queue.Empty:
                return(False, None)
            return(True, result)
        return self._queue.get()
1083212
private static <T> T reportGet(Object r)
        throws InterruptedException, ExecutionException {
        if (r == null) // by convention below, null means interrupted
            throw new InterruptedException();
        if (r instanceof AltResult) {
            Throwable x, cause;
            if ((x = ((AltResult)r).ex) == null)
                return null;
            if (x instanceof CancellationException)
                throw (CancellationException)x;
            if ((x instanceof CompletionException) &&
                (cause = x.getCause()) != null)
                x = cause;
            throw new ExecutionException(x);
        }
        @SuppressWarnings("unchecked") T t = (T) r;
        return t;
    }
91087
@Nullable
  static ClientTransport getTransportFromPickResult(PickResult result, boolean isWaitForReady) {
    final ClientTransport transport;
    Subchannel subchannel = result.getSubchannel();
    if (subchannel != null) {
      transport = ((AbstractSubchannel) subchannel).obtainActiveTransport();
    } else {
      transport = null;
    }
    if (transport != null) {
      final ClientStreamTracer.Factory streamTracerFactory = result.getStreamTracerFactory();
      if (streamTracerFactory == null) {
        return transport;
      }
      return new ClientTransport() {
        @Override
        public ClientStream newStream(
            MethodDescriptor<?, ?> method, Metadata headers, CallOptions callOptions) {
          return transport.newStream(
              method, headers, callOptions.withStreamTracerFactory(streamTracerFactory));
        }

        @Override
        public void ping(PingCallback callback, Executor executor) {
          transport.ping(callback, executor);
        }

        @Override
        public InternalLogId getLogId() {
          return transport.getLogId();
        }

        @Override
        public ListenableFuture<SocketStats> getStats() {
          return transport.getStats();
        }
      };
    }
    if (!result.getStatus().isOk()) {
      if (result.isDrop()) {
        return new FailingClientTransport(result.getStatus(), RpcProgress.DROPPED);
      }
      if (!isWaitForReady) {
        return new FailingClientTransport(result.getStatus(), RpcProgress.PROCESSED);
      }
    }
    return null;
  }
1210681
@Override
    public void _waitForNonStaleResults(Duration waitTimeout) {
        theWaitForNonStaleResults = true;
        timeout = ObjectUtils.firstNonNull(waitTimeout, getDefaultTimeout());
    }
1113310
@SuppressWarnings("unchecked")
  T result(final Object r) {
    return (T) (r == NULL ? null : r);
  }
820879
public Object poll(long timeout) throws InterruptedException {

        Object old = null;

        // D220640: Next two lines pulled out of synchronization block:

        // E2E optimized long start = (timeout <= 0) ? 0 :
        // System.currentTimeMillis();
        long start = (timeout <= 0) ? 0 : -1;
        long waitTime = timeout;

        // D312598 - begin
        while (true) {
            synchronized (this) {
                if (numberOfUsedSlots.get() > 0) {
                    old = extract();
                    numberOfUsedSlots.getAndDecrement();
                }
                if (old != null) {
                    // PK77809 Decrement the number of waiting threads since we will be
                    // returning a work item to a waiting thread to execute.
                    waitingThreads--;
                }
            }

            if (old != null) {
                notifyPut_();
                return old;
            }

            if (start == -1)
                start = System.currentTimeMillis();

            int spinctr = SPINS_TAKE_;
            while (numberOfUsedSlots.get() <= 0) {
                if (waitTime <= 0) {
                    return null;
                }
                // busy wait
                if (spinctr > 0) {
                    if (YIELD_TAKE_)
                        Thread.yield();
                    spinctr--;
                } else {
                    // block on lock
                    waitGet_(waitTime);
                }
                waitTime = timeout - (System.currentTimeMillis() - start);
            }
        }
        // D312598 - end

    }