Implements an exponential backoff delay for use with {@link Mono#repeatWhenEmpty(Function)}

@param minimum the minimum duration
@param maximum the maximum duration
@param timeout the maximum amount of time to delay for
@return a delayed {@link Publisher}
508767
public static Function<Flux<Long>, Publisher<?>> exponentialBackOff(Duration minimum, Duration maximum, Duration timeout) {
        Instant finish = Instant.now().plus(timeout);
        return iterations -> getDelay(minimum, maximum, finish, iterations);
    }
646914
public long backoff(int attempt) {
    long duration = base * (long) Math.pow(factor, attempt);
    if (jitter != 0) {
      double random = Math.random();
      int deviation = (int) Math.floor(random * jitter * duration);
      if ((((int) Math.floor(random * 10)) & 1) == 0) {
        duration = duration - deviation;
      } else {
        duration = duration + deviation;
      }
    }
    if (duration < 0) {
      duration = Long.MAX_VALUE;
    }
    return Math.min(Math.max(duration, base), cap);
  }
909836
public synchronized Operation timeout(@Nullable final Long timeout) {
        this.timeout = timeout == null || timeout > 0 ? timeout : null;
        return this;
    }
54469
public final void setMinimumDuration(Duration duration) {
        Objects.requireNonNull(duration);
        if (minimumDuration != null) {
            minimumDuration.set(duration);
        } else {
            _minimumDuration = duration;
        }
    }
1203799
public SwimMembershipProtocolConfig setFailureTimeout(Duration failureTimeout) {
    checkNotNull(failureTimeout, "failureTimeout cannot be null");
    checkArgument(!failureTimeout.isNegative() && !failureTimeout.isZero(), "failureTimeout must be positive");
    this.failureTimeout = checkNotNull(failureTimeout);
    return this;
  }
1273639
function (minimumInterval, callback) {
    var timeout = null;
    return function () {
        var that = this, args = arguments;
        if(timeout === null) {
            timeout = setTimeout(function () {
                timeout = null;
            }, minimumInterval);
            callback.apply(that, args);
        }
    };
}
460972
public void setWriteTimeout(int writeTimeout) {
		this.client = this.client.newBuilder()
				.writeTimeout(writeTimeout, TimeUnit.MILLISECONDS)
				.build();
	}
187221
public Retryer<R> randomWait(final long minimum, final long maximum) {
        checkArgument(minimum >= 0, "minimum must be >= 0 but is %d", minimum);
        checkArgument(maximum > minimum, "maximum must be > minimum but maximum is %d and minimum is", maximum, minimum);
        
        final Random random = new Random();
        return withWaitStrategy(new WaitStrategy() {
            @Override public long computeSleepTime(int previousAttemptNumber, long delaySinceFirstAttemptInMillis) {
                long t = Math.abs(random.nextLong()) % (maximum - minimum);
                return t + minimum;
            }
        });
    }
1308279
public static <T> Supplier<T> debounce(final Supplier<T> function, final int delayMilliseconds) {
        return new Supplier<T>() {
            private java.util.concurrent.ScheduledFuture<T> timeout;

            @Override
            public T get() {
                clearTimeout(timeout);
                timeout = delay(function, delayMilliseconds);
                return null;
            }
        };
    }
729992
@Override
    public IPromise<T> awaitPromise(long timeout) {
        long endtime = 0;
        if ( timeout > 0 ) {
            endtime = System.currentTimeMillis() + timeout;
        }
        if ( Thread.currentThread() instanceof DispatcherThread ) {
            DispatcherThread dt = (DispatcherThread) Thread.currentThread();
            Scheduler scheduler = dt.getScheduler();
            int idleCount = 0;
            dt.__stack.add(this);
            while( ! isSettled() ) {
                if ( ! dt.pollQs() ) {
                    idleCount++;
                    scheduler.pollDelay(idleCount);
                } else {
                    idleCount = 0;
                }
                if ( endtime != 0 && System.currentTimeMillis() > endtime && ! isSettled() ) {
                    timedOut(Timeout.INSTANCE);
                    break;
                }
            }
            dt.__stack.remove(dt.__stack.size()-1);
            return this;
        } else {
            // if outside of actor machinery, just block
            CountDownLatch latch = new CountDownLatch(1);
            then( (res, err) -> {
                latch.countDown();
            });
            boolean timedOut = false;
            try {
                timedOut = ! latch.await(timeout, TimeUnit.MILLISECONDS);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if ( timedOut )
                timedOut(Timeout.INSTANCE);
            return this;
        }
    }
276784
public boolean waitForEmptyActivityStack(int timeout)
	{
		if(config.commandLogging){
			Log.d(config.commandLoggingTag, "waitForEmptyActivityStack("+timeout+")");
		}
		
		return waiter.waitForCondition(
				new Condition(){
					@Override
					public boolean isSatisfied() {
						return activityUtils.isActivityStackEmpty();
					}
				}, timeout);
	}
613138
func PublisherTimeout(timeout time.Duration) PublisherOption {
	return func(p *Publisher) { p.timeout = timeout }
}
306800
private long getTimeoutMillis(String type, Duration timeout) {
    return timeout != null ? timeout.toMillis() : computeTimeoutMillis(type);
  }
981992
public CircuitBreaker<R> withDelay(Duration delay) {
    Assert.notNull(delay, "delay");
    Assert.isTrue(delay.toNanos() >= 0, "delay must not be negative");
    this.delay = delay;
    return this;
  }
886839
public RetryBuilder delay(Delay delay, Scheduler scheduler) {
    this.delay = (delay == null) ? Retry.DEFAULT_DELAY : delay;
    this.scheduler = scheduler;
    return this;
  }
955979
public int fillWithTimeout(long timeout)
    throws IOException
  {
    if (_readOffset < _readLength) {
      return _readLength - _readOffset;
    }

    if (_readBuffer == null) {
      _readOffset = 0;
      _readLength = 0;
      return -1;
    }

    _readOffset = 0;
    StreamImpl source = _source;

    if (source == null) {
      // return true on end of file
      return -1;
    }

    int readLength
      = source.readTimeout(_readBuffer, 0, _readBuffer.length, timeout);

    if (readLength > 0) {
      _readLength = readLength;
      _position += readLength;

      if (_isEnableReadTime) {
        _readTime = CurrentTime.currentTime();
      }

      return readLength;
    }
    else if (readLength == READ_TIMEOUT) {
      // timeout
      _readLength = 0;
      return 0;
    }
    else {
      // return false on end of file
      _readLength = 0;
      return -1;
    }
  }
1341431
public RetryInterceptorBuilder<T> backOffOptions(long initialInterval,
			double multiplier, long maxInterval) {
		Assert.isNull(this.retryOperations,
				"cannot set the back off policy when a custom retryOperations has been set");
		Assert.isTrue(!this.backOffPolicySet,
				"cannot set the back off options when a back off policy has been set");
		ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
		policy.setInitialInterval(initialInterval);
		policy.setMultiplier(multiplier);
		policy.setMaxInterval(maxInterval);
		this.retryTemplate.setBackOffPolicy(policy);
		this.backOffOptionsSet = true;
		this.templateAltered = true;
		return this;
	}