예제 #1
0
        internal static RateLimiter Create(ISleepingStopwatch stopwatch, double permitsPerSecond)
        {
            var rateLimiter = new SmoothRateLimiter.SmoothBursty(stopwatch, 1.0 /* maxBurstSeconds */);

            rateLimiter.SetRate(permitsPerSecond);
            return(rateLimiter);
        }
예제 #2
0
        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);
        }
예제 #3
0
        protected RateLimiter(ISleepingStopwatch stopwatch)
        {
            if (stopwatch == null)
            {
                throw new ArgumentNullException(nameof(stopwatch));
            }

            this._stopwatch = stopwatch;
        }
예제 #4
0
        private long _nextFreeTicketMicros; // could be either in the past or future

        private SmoothRateLimiter(ISleepingStopwatch stopwatch) : base(stopwatch)
        {
        }
예제 #5
0
 public SmoothBursty(ISleepingStopwatch stopwatch, double maxBurstSeconds) : base(stopwatch)
 {
     _maxBurstSeconds = maxBurstSeconds;
 }
예제 #6
0
 public SmoothWarmingUp(ISleepingStopwatch stopwatch, long warmupPeriod, TimeUnit timeUnit, double coldFactor) : base(stopwatch)
 {
     _warmupPeriodMicros = timeUnit.ToMicros(warmupPeriod);
     _coldFactor         = coldFactor;
 }