internal static RateLimiter Create(ISleepingStopwatch stopwatch, double permitsPerSecond) { var rateLimiter = new SmoothRateLimiter.SmoothBursty(stopwatch, 1.0 /* maxBurstSeconds */); rateLimiter.SetRate(permitsPerSecond); return(rateLimiter); }
internal static RateLimiter Create(ISleepingStopwatch stopwatch, double permitsPerSecond, long warmupPeriod, TimeUnit unit, double coldFactor) { RateLimiter rateLimiter = new SmoothRateLimiter.SmoothWarmingUp(stopwatch, warmupPeriod, unit, coldFactor); rateLimiter.SetRate(permitsPerSecond); return(rateLimiter); }
protected RateLimiter(ISleepingStopwatch stopwatch) { if (stopwatch == null) { throw new ArgumentNullException(nameof(stopwatch)); } this._stopwatch = stopwatch; }
private long _nextFreeTicketMicros; // could be either in the past or future private SmoothRateLimiter(ISleepingStopwatch stopwatch) : base(stopwatch) { }
public SmoothBursty(ISleepingStopwatch stopwatch, double maxBurstSeconds) : base(stopwatch) { _maxBurstSeconds = maxBurstSeconds; }
public SmoothWarmingUp(ISleepingStopwatch stopwatch, long warmupPeriod, TimeUnit timeUnit, double coldFactor) : base(stopwatch) { _warmupPeriodMicros = timeUnit.ToMicros(warmupPeriod); _coldFactor = coldFactor; }