{@inheritDoc}

@param timeout  {@inheritDoc}
@param timeUnit {@inheritDoc}

@throws CouldNotPerformException       {@inheritDoc}
@throws java.lang.InterruptedException {@inheritDoc}
768978
@Override
    public void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException {
        try {
            if (isDataAvailable()) {
                return;
            }
            long startTime = System.currentTimeMillis();
            getDataFuture().get(timeout, timeUnit);
            long partialTimeout = timeUnit.toMillis(timeout) - (System.currentTimeMillis() - startTime);
            if (partialTimeout <= 0) {
                throw new java.util.concurrent.TimeoutException("Data timeout is reached!");
            }
            dataObservable.waitForValue(partialTimeout, TimeUnit.MILLISECONDS);
        } catch (java.util.concurrent.TimeoutException | CouldNotPerformException | ExecutionException | CancellationException ex) {
            if (shutdownInitiated) {
                throw new InterruptedException("Interrupt request because system shutdown was initiated!");
            }
            throw new NotAvailableException("Data is not yet available!", ex);
        }
    }
377893
public static void joinUninterruptibly(Thread toJoin,
      long timeout, TimeUnit unit) {
    Preconditions.checkNotNull(toJoin);
    boolean interrupted = false;
    try {
      long remainingNanos = unit.toNanos(timeout);
      long end = System.nanoTime() + remainingNanos;
      while (true) {
        try {
          // TimeUnit.timedJoin() treats negative timeouts just like zero.
          NANOSECONDS.timedJoin(toJoin, remainingNanos);
          return;
        } catch (InterruptedException e) {
          interrupted = true;
          remainingNanos = end - System.nanoTime();
        }
      }
    } finally {
      if (interrupted) {
        Thread.currentThread().interrupt();
      }
    }
  }
1282165
public ResourcePoolConfig setTimeout(long timeout, TimeUnit unit) {
        if(timeout < 0)
            throw new IllegalArgumentException("The timeout must be a non-negative number.");
        this.timeoutNs = TimeUnit.NANOSECONDS.convert(timeout, unit);
        return this;
    }
1228443
public boolean awaitCompletion(long timeout, TimeUnit timeUnit) throws InterruptedException {
        boolean result = completed.await(timeout, timeUnit);
        throwFirstError();
        return result;
    }
1134402
protected Lock tryLockForWrite(long time, TimeUnit unit) throws InterruptedException {
        if (time < 0 || unit == null) {
            return tryLockForWrite();
        }
        Lock lock = writeLock();
        return lock.tryLock(time, unit) ? lock : null;
    }
420139
public synchronized Response<ByteArray, Object> responseQueuePoll(long timeout,
                                                                      TimeUnit timeUnit)
            throws InterruptedException {
        long timeoutMs = timeUnit.toMillis(timeout);
        long timeoutWallClockMs = System.currentTimeMillis() + timeoutMs;
        while(responseQueue.isEmpty() && System.currentTimeMillis() < timeoutWallClockMs) {
            long remainingMs = Math.max(0, timeoutWallClockMs - System.currentTimeMillis());
            if(logger.isDebugEnabled()) {
                logger.debug("Start waiting for response queue with timeoutMs: " + timeoutMs);
            }
            this.wait(remainingMs);
            if(logger.isDebugEnabled()) {
                logger.debug("End waiting for response queue with timeoutMs: " + timeoutMs);
            }
        }
        return responseQueue.poll();
    }
1157904
public Retryer<R> timeout(long duration, TimeUnit timeUnit) {
        return timeout(duration, timeUnit, null);
    }
458765
public CompletableFuture<T> orTimeout(long timeout, TimeUnit unit) {
        if (unit == null)
            throw new NullPointerException();
        if (result == null)
            whenComplete(new Canceller(Delayer.delay(new Timeout(this),
                                                     timeout, unit)));
        return this;
    }
659551
@Override
  public <T> T run(long timeout,
                   TimeUnit unit,
                   Consumer<Result<T>> task)
  {
    return delegate().run(timeout, unit, task);
  }
968932
public Retryer<R> timeout(final TimeLimiter timeLimiter, final long duration, final TimeUnit timeUnit) {
        return withTimelimiter(new AttemptTimelimit<R>() {

            @Override public R call(Callable<R> callable) throws Exception {
                return checkNotNull(timeLimiter, "TimeLimiter cannot be null")
                        .callWithTimeout(callable, duration, checkNotNull(timeUnit), true);
            }
        });
    }
284517
public SendResult send(MessageBuilder builder, long timeout, TimeUnit unit) throws InterruptedException {
        Message msg = builder.build(this.messageBodyConverter);
        final String topic = msg.getTopic();
        MessageProducer producer = this.getOrCreateProducer(topic);
        try {
            return producer.sendMessage(msg, timeout, unit);
        }
        catch (MetaClientException e) {
            return new SendResult(false, null, -1, ExceptionUtils.getFullStackTrace(e));
        }
    }
721180
public void setLockTimeout(int timeout, TimeUnit unit) {
        if (timeout < 0 || unit == null) {
            throw new IllegalArgumentException();
        }
        mLockTimeout = timeout;
        mLockTimeoutUnit = unit;
    }
436724
protected TimeoutId requestTimeout(final long delay, final TimeUnit unit, @Nullable final String name, @Nullable final Object data) {
        return timeoutManager.requestTimeout(context(), state().getSagaId(), delay, unit, name, data);
    }
644600
public SleepBuilder<T> withTimeout(long timeout, TimeUnit timeUnit) {
        this.timeout = timeUnit.toMillis(timeout);
        return this;
    }
368216
public void await(long weight, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
        barrier.await(weight, timeout, unit);
    }
458678
public void await(Event event, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
        long timestamp = getTimestamp(event);
        try {
            lock.lockInterruptibly();
            single(timestamp);
            while (isPermit(event, timestamp) == false) {
                condition.await(timeout, unit);
            }
        } finally {
            lock.unlock();
        }
    }
313308
public CommandEvent readEvent(int timeout, TimeUnit unit) throws Exception {

        checkConnected();

        connection.setReadTimeout((int) unit.toMillis(timeout));

        CommandEvent event = null;
        String eventType = textIn.readLine();

        if (Thread.interrupted())
        {
            throw new InterruptedException("thread interrupted during blocking read");
        }

        if (eventType != null) {
            switch (eventType) {
            case PREPARED_EVENT:
                event = readPreparedEvent();
                break;
            case STARTED_EVENT:
                event = readStartedEvent();
                break;
            case ERROR_EVENT:
                event = readErrorEvent();
                break;
            case FINISHED_EVENT:
                event = readFinishedEvent();
                break;
            case NOTIFIED_EVENT:
                event = readNotifiedEvent();
                break;
            default:
                throw new IllegalStateException("Invalid protocol frame: " + eventType);
            }
        }

        return event;
    }