Пример #1
0
        public RequestQueueBucket(RequestQueue queue, Bucket definition, RequestQueueBucket parent = null)
        {
            _queue     = queue;
            Definition = definition;
            if (definition.WindowCount != 0)
            {
                _semaphore = new SemaphoreSlim(definition.WindowCount, definition.WindowCount);
            }
            Parent = parent;

            _pauseLock      = new object();
            _resumeNotifier = new TaskCompletionSource <byte>();
            _resumeNotifier.SetResult(0);
        }
Пример #2
0
        public RequestBucket(RequestQueue queue, RestRequest request, string id)
        {
            _queue = queue;
            Id     = id;

            _lock = new object();

            if (request.Options.IsClientBucket)
            {
                WindowCount = ClientBucket.Get(request.Options.BucketId).WindowCount;
            }
            else
            {
                WindowCount = 1; //Only allow one request until we get a header back
            }
            _semaphore    = WindowCount;
            _resetTick    = null;
            LastAttemptAt = DateTimeOffset.UtcNow;
        }