/// <summary> /// Creates a new instance of the <see cref="RateLimiter" /> class. /// </summary> /// <param name="minimumInterval">The minimum time between events.</param> /// <param name="targetInterval">The target average time between events.</param> /// <param name="timeWindow">The time span over which the average rate is calculated.</param> public RateLimiter(TimeSpan minimumInterval, TimeSpan targetInterval, TimeSpan timeWindow) { _window = new List<DateTime>(); _lock = new AsyncLock(); _minimumInterval = minimumInterval; _targetInterval = targetInterval; _timeWindowDuration = timeWindow; _maxAllowedInWindow = (int) (timeWindow.Ticks/targetInterval.Ticks); _lastTake = DateTime.Now - minimumInterval; }
internal Releaser(AsyncLock toRelease) { _toRelease = toRelease; }