Пример #1
0
        /// <summary>
        /// Initializes the <see cref="ConcurrencyLimiter"/>.
        /// </summary>
        /// <param name="options">Options to specify the behavior of the <see cref="ConcurrencyLimiter"/>.</param>
        public ConcurrencyLimiter(ConcurrencyLimiterOptions options)
        {
            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (options.PermitLimit <= 0)
            {
                throw new ArgumentException($"{nameof(options.PermitLimit)} must be set to a value greater than 0.", nameof(options));
            }
            if (options.QueueLimit < 0)
            {
                throw new ArgumentException($"{nameof(options.QueueLimit)} must be set to a value greater than or equal to 0.", nameof(options));
            }

            _options = new ConcurrencyLimiterOptions
            {
                PermitLimit          = options.PermitLimit,
                QueueProcessingOrder = options.QueueProcessingOrder,
                QueueLimit           = options.QueueLimit
            };

            _permitCount = _options.PermitLimit;
        }
Пример #2
0
 /// <summary>
 /// Initializes the <see cref="ConcurrencyLimiter"/>.
 /// </summary>
 /// <param name="options">Options to specify the behavior of the <see cref="ConcurrencyLimiter"/>.</param>
 public ConcurrencyLimiter(ConcurrencyLimiterOptions options)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     _permitCount = _options.PermitLimit;
 }
 /// <summary>
 /// Initializes the <see cref="ConcurrencyLimiter"/>.
 /// </summary>
 /// <param name="options">Options to specify the behavior of the <see cref="ConcurrencyLimiter"/>.</param>
 public ConcurrencyLimiter(ConcurrencyLimiterOptions options)
 {
     _options     = options;
     _permitCount = _options.PermitLimit;
 }
Пример #4
0
 /// <summary>
 /// Initializes the <see cref="ConcurrencyLimiter"/>.
 /// </summary>
 /// <param name="options">Options to specify the behavior of the <see cref="ConcurrencyLimiter"/>.</param>
 public ConcurrencyLimiter(ConcurrencyLimiterOptions options !!)
 {