Sleeps before retry ; default implementation is exponential back-off, or the specified duration

@param currentTries 1 after first fail, then 2, 3 ... up to nbTriesMax-1.
@param optDuration_ms if positive, the delay to apply
167843
private void doWait( int currentTries, long optDuration_ms )
    {
        if ( optDuration_ms < 0 ) {
            optDuration_ms = ( long ) ( firstSleep_ms * ( Math.random() + 0.5 ) * ( 1L << ( currentTries - 1 ) ) );
        }

        LOGGER.debug( "Will retry request after {} millis", optDuration_ms );

        try {
            Thread.sleep( optDuration_ms );
        } catch ( InterruptedException ex ) {
            throw new CStorageException( "Retry waiting interrupted", ex );
        }
    }
72310
<T> T callWithRetries(Callable<T> callable, RecurringPolicy<?> recurringPolicy,
      RecurringStats retryStats, Set<Class<? extends Exception>> retryableExceptions,
      boolean recoverable, boolean logFailures) throws Exception {
    boolean recovery = retryStats != null;

    while (true) {
      try {
        return callable.call();
      } catch (Exception e) {
        ShutdownSignalException sse = extractCause(e, ShutdownSignalException.class);
        if (sse == null && logFailures && recurringPolicy != null
            && recurringPolicy.allowsAttempts())
          log.error("Invocation of {} failed.", callable, e);

        if (sse != null && (recovery || !recoverable))
          throw e;

        if (!closed) {
          try {
            // Retry on channel recovery failure or retryable exception
            boolean retryable =
                recurringPolicy != null && recurringPolicy.allowsAttempts()
                    && isRetryable(retryableExceptions, e, sse);
            long startTime = System.nanoTime();

            if (retryable) {
              if (retryStats == null) 
                retryStats = new RecurringStats(recurringPolicy);
                
              // Wait for pending recovery
              if (sse != null) {
                if (recurringPolicy.getMaxDuration() == null)
                  circuit.await();
                else if (!circuit.await(retryStats.getMaxWaitTime())) {
                  log.debug("Exceeded max wait time while waiting for {} to recover", this);
                  throw e;
                }
              }

              // Continue retries
              retryStats.incrementAttempts();
              if (!retryStats.isPolicyExceeded()) {
                long remainingWaitTime =
                    retryStats.getWaitTime().toNanos() - (System.nanoTime() - startTime);
                if (remainingWaitTime > 0)
                  retryWaiter.await(Duration.nanos(remainingWaitTime));
                continue;
              }
            }
          } catch (Throwable ignore) {
          }
        }

        throw e;
      }
    }
  }
434441
function TxPowerModeCharateristic(opts) {
	TxPowerModeCharateristic.super_.call(this, objectAssign({
		uuid: 'ee0c2087-8786-40ba-ab96-99b91ac981d8',
		properties: ['read', 'write'],
		sizeof: 1
	}, opts));

	this.removeAllListeners('beforeWrite');

	this.on('beforeWrite', function(data, res) {
		var err = Results.Success;
		var value = this.fromBuffer(data);
		if (data.length !== 1) {
			err = Results.InvalidAttributeLength;
		} else if (value < TxPowerMode.Lowest || value > TxPowerMode.High) {
			err = Results.WriteNotPermitted;
		}

		res(err);
	});
}
393014
protected static void scheduleNextRetry(ClientRequestContext ctx,
                                            Consumer<? super Throwable> actionOnException,
                                            Runnable retryTask, long nextDelayMillis) {
        try {
            if (nextDelayMillis == 0) {
                ctx.contextAwareEventLoop().execute(retryTask);
            } else {
                @SuppressWarnings("unchecked")
                final ScheduledFuture<Void> scheduledFuture = (ScheduledFuture<Void>) ctx
                        .contextAwareEventLoop().schedule(retryTask, nextDelayMillis, TimeUnit.MILLISECONDS);
                scheduledFuture.addListener(future -> {
                    if (future.isCancelled()) {
                        // future is cancelled when the client factory is closed.
                        actionOnException.accept(new IllegalStateException(
                                ClientFactory.class.getSimpleName() + " has been closed."));
                    }
                });
            }
        } catch (Throwable t) {
            actionOnException.accept(t);
        }
    }
201402
public Retryer<R> stopAfterDelay(final long delayInMillis) {
        checkArgument(delayInMillis >= 0L, "delayInMillis must be >= 0 but is %d", delayInMillis);
        return withStopStrategy(new StopStrategy() {
            
            @Override public boolean shouldStop(int previousAttemptNumber, long delaySinceFirstAttemptInMillis) {
                return delaySinceFirstAttemptInMillis >= delayInMillis;
            }
        });
    }
609172
protected void setTiming(boolean monitor, long t0, MessageToClient mtc) {
		if (monitor) {
			long t1 = System.currentTimeMillis();
			mtc.setTime(t1 - t0);
		}
	}
929526
public void sessionMaxInactiveTimeSet(ISession session, int old, int newval) {
        // ArrayList sessionStateObservers = null;

        /*
         * Check to see if there is a non-empty list of sessionStateObservers.
         */
        if (_sessionStateObservers == null || _sessionStateObservers.size() < 1) {
            return;
        }

        // synchronized(_sessionStateObservers) {
        // sessionStateObservers = (ArrayList)_sessionStateObservers.clone();
        // }

        ISessionStateObserver sessionStateObserver = null;
        for (int i = 0; i < _sessionStateObservers.size(); i++) {
            sessionStateObserver = (ISessionStateObserver) _sessionStateObservers.get(i);
            sessionStateObserver.sessionMaxInactiveTimeSet(session, old, newval);
        }
    }
49928
private function _pauseOnRetry($retries)
    {
        if ($retries <= $this->_config['MaxErrorRetry']) {
            $delay = (int) (pow(4, $retries) * 100000);
            usleep($delay);
            return true;
        } 
        return false;
    }
1315366
public static RejectedExecutionHandler backoff(final int retries, long backoffAmount, TimeUnit unit) {
        ObjectUtil.checkPositive(retries, "retries");
        final long backOffNanos = unit.toNanos(backoffAmount);
        return new RejectedExecutionHandler() {
            @Override
            public void rejected(Runnable task, SingleThreadEventExecutor executor) {
                if (!executor.inEventLoop()) {
                    for (int i = 0; i < retries; i++) {
                        // Try to wake up the executor so it will empty its task queue.
                        executor.wakeup(false);

                        LockSupport.parkNanos(backOffNanos);
                        if (executor.offerTask(task)) {
                            return;
                        }
                    }
                }
                // Either we tried to add the task from within the EventLoop or we was not able to add it even with
                // backoff.
                throw new RejectedExecutionException();
            }
        };
    }
344598
private function pauseOnRetry($retries, $status)
    {
        if ($retries <= self::MAX_ERROR_RETRY) {
            // PHP delays are in microseconds (1 million microsecond = 1 sec)
            // 1st delay is (4^1) * 100000 + 600000 = 0.4 + 0.6 second = 1.0 sec
            // 2nd delay is (4^2) * 100000 + 600000 = 1.6 + 0.6 second = 2.2 sec
            // 3rd delay is (4^3) * 100000 + 600000 = 6.4 + 0.6 second = 7.0 sec
            $delay = (int) (pow(4, $retries) * 100000) + 600000;
            usleep($delay);
        } else {
            throw new \Exception('Error Code: '. $status.PHP_EOL.'Maximum number of retry attempts - '. $retries .' reached');
        }
    }
1073336
private void setInactivityTimer(long ms) {
        if (sessionInactivityTimer == null) {
            sessionInactivityTimer = new SessionInactivityTimer(sessionHandler.getScheduler(), this);
        }
        sessionInactivityTimer.setIdleTimeout(ms);
    }
886839
public RetryBuilder delay(Delay delay, Scheduler scheduler) {
    this.delay = (delay == null) ? Retry.DEFAULT_DELAY : delay;
    this.scheduler = scheduler;
    return this;
  }
1184813
public boolean withEveryRetryWaitFor(int time, TimeUnit units) {
        for (int i = 1; i <= retries; i++) {
            if (openSocket()) {
                return true;
            }
            sleepFor(time, units);
        }
        return false;
    }
1357910
public void advance(long currentTimeNanos) {
    long previousTimeNanos = nanos;
    try {
      nanos = currentTimeNanos;
      for (int i = 0; i < SHIFT.length; i++) {
        long previousTicks = (previousTimeNanos >> SHIFT[i]);
        long currentTicks = (currentTimeNanos >> SHIFT[i]);
        if ((currentTicks - previousTicks) <= 0L) {
          break;
        }
        expire(i, previousTicks, currentTicks);
      }
    } catch (Throwable t) {
      nanos = previousTimeNanos;
      throw t;
    }
  }
104516
private void sleepBetweenHostSkips(FailoverPolicy failoverPolicy) {
    if (failoverPolicy.sleepBetweenHostsMilli > 0) {
      if ( log.isDebugEnabled() ) {
        log.debug("Will sleep for {} millisec", failoverPolicy.sleepBetweenHostsMilli);
      }
      try {
        Thread.sleep(failoverPolicy.sleepBetweenHostsMilli);
      } catch (InterruptedException e) {
        log.warn("Sleep between hosts interrupted", e);
      }
    }
  }
1158802
@Override
    public void retry(JusError error) throws JusError {
        if(errorFilter != null && !errorFilter.apply(error)) {
            throw error;
        }
        mCurrentRetryCount++;
        currentTimeoutMs = (int) (currentTimeoutMs * backoffMultiplier);
        if (!hasAttemptRemaining()) {
            throw error;
        }
    }
239117
def retry(self, queue=None, delay=None, max_retries=None):
        

        max_retries = max_retries
        if max_retries is None:
            max_retries = self.max_retries

        if self.data.get("retry_count", 0) >= max_retries:
            raise MaxRetriesInterrupt()

        exc = RetryInterrupt()

        exc.queue = queue or self.queue or self.data.get("queue") or "default"
        exc.retry_count = self.data.get("retry_count", 0) + 1
        exc.delay = delay
        if exc.delay is None:
            exc.delay = self.retry_delay

        self._attach_original_exception(exc)

        raise exc