Timing out after the specified time limit with {@link TimeLimiter}

@param timeLimiter
@param duration
@param timeUnit
@return
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);
            }
        });
    }
898325
public static <V> Predicate<TaskContext<V>> afterDelay(long time, TimeUnit timeUnit) {
        return ctx -> (System.currentTimeMillis() - ctx.getStartTime()) >= timeUnit.toMillis(time);
    }
693266
public static Duration of(String duration) {
    Matcher matcher = PATTERN.matcher(duration);
    Assert.arg(matcher.matches(), "Invalid duration: %s", duration);

    if (matcher.group(1) != null) {
      return Duration.ofSeconds(Long.MAX_VALUE);
    } else {
      String unit = matcher.group(4);
      String value = matcher.group(3);
      return Duration.ofNanos(TimeUnit.NANOSECONDS.convert(Long.parseLong(value),
          unit == null ? TimeUnit.MILLISECONDS : SUFFIXES.get(unit)));
    }
  }
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;
    }
894855
public <T extends CacheSpec<K, V>> T expiresAfterWrite(String duration) {
      this.expiresAfterWrite = convertStringToTime(duration);
      return Cast.as(this);
   }
993624
public void setConnectTimeout(long connectTimeout, TimeUnit unit) {
        this.connectTimeout = Duration.ofMillis(unit.toMillis(connectTimeout));
    }
1087768
@SuppressWarnings("unchecked")
  public T withMaxDuration(Duration maxDuration) {
    Assert.notNull(maxDuration, "maxDuration");
    this.maxDuration = maxDuration;
    return (T) this;
  }
311385
public void setTimeout(long timeout, TimeUnit unit) {
        this.timeout = timeout;
        this.unit    = unit;
        c.setTimeout(timeout, unit);
    }
992937
public CallOptions withDeadlineAfter(long duration, TimeUnit unit) {
    return withDeadline(Deadline.after(duration, unit));
  }
1091501
@Override
    public Configuration defaultInterval(long time, TimeUnit unit) {
        return defaultInterval(new Duration(time, unit));
    }
1345469
public RetryerBuilder<V> withAttemptTimeLimiter(@Nonnull AttemptTimeLimiter<V> attemptTimeLimiter) {
        Preconditions.checkNotNull(attemptTimeLimiter);
        this.attemptTimeLimiter = attemptTimeLimiter;
        return this;
    }
1246572
public void setSessionTimeout(Long timeout, TimeUnit unit) {
        long t = unit.toMillis(timeout);
        properties.put("request.timeout.ms", String.valueOf(t + 60000));
        properties.put("session.timeout.ms", String.valueOf(t));
    }
1367787
public Retryer<R> timeout(long duration, TimeUnit timeUnit, ExecutorService executor) {
        return timeout(null == executor
                ? new SimpleTimeLimiter() : new SimpleTimeLimiter(executor), duration, timeUnit);
    }
907940
public final S withDeadlineAfter(long duration, TimeUnit unit) {
    return build(channel, callOptions.withDeadlineAfter(duration, unit));
  }
1188862
public static TimeoutException newTimeoutException(long timeout, TimeUnit unit, java.util.concurrent.TimeoutException cause) {
        return new TimeoutException(timeout, unit, cause);
    }
1209577
public static void updateTimer(Optional<Timer> timer, final long duration, final TimeUnit unit) {
    timer.transform(new Function<Timer, Timer>() {
      @Override
      public Timer apply(@Nonnull Timer input) {
        input.update(duration, unit);
        return input;
      }
    });
  }
721180
public void setLockTimeout(int timeout, TimeUnit unit) {
        if (timeout < 0 || unit == null) {
            throw new IllegalArgumentException();
        }
        mLockTimeout = timeout;
        mLockTimeoutUnit = unit;
    }