/** * Create a strategy whose time periods increase exponentially. * * @param clock the clock used to determine if sufficient time has elapsed; may not be null * @param initialDelayInMilliseconds the initial delay; must be positive * @param maxDelayInMilliseconds the maximum delay; must be greater than the initial delay * @return the strategy; never null */ public static ElapsedTimeStrategy exponential(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds) { return exponential(clock, initialDelayInMilliseconds, maxDelayInMilliseconds, 2.0); }
pollOutputDelay = ElapsedTimeStrategy.exponential(clock, INITIAL_POLL_PERIOD_IN_MILLIS, MAX_POLL_PERIOD_IN_MILLIS);
/** * Create a strategy whose time periods increase exponentially. * * @param clock the clock used to determine if sufficient time has elapsed; may not be null * @param initialDelayInMilliseconds the initial delay; must be positive * @param maxDelayInMilliseconds the maximum delay; must be greater than the initial delay * @return the strategy; never null */ public static ElapsedTimeStrategy exponential(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds) { return exponential(clock, initialDelayInMilliseconds, maxDelayInMilliseconds, 2.0); }
@Test public void testExponentialDelay() { clock.advanceTo(100); delay = ElapsedTimeStrategy.exponential(clock, 100, 4000);