コード例 #1
0
            private object Dequeue()
            {
                var element = _inputBuffer[_nextInputElementCursor];

                if (element == null)
                {
                    throw new IllegalStateException("Internal queue must never contain a null");
                }
                _inputBuffer[_nextInputElementCursor] = null;

                _batchRemaining--;
                if (_batchRemaining == 0 && !_upstreamCompleted)
                {
                    ReactiveStreamsCompliance.TryRequest(_upstream, _requestBatchSize);
                    _batchRemaining = _requestBatchSize;
                }

                _inputBufferElements--;
                _nextInputElementCursor = (_nextInputElementCursor + 1) & _indexMask;
                return(element);
            }
コード例 #2
0
 public void OnSubscribe(ISubscription subscription)
 {
     if (subscription == null)
     {
         throw new ArgumentException("Subscription cannot be null");
     }
     if (_upstreamCompleted)
     {
         ReactiveStreamsCompliance.TryCancel(subscription);
     }
     else if (_downstreamCanceled)
     {
         _upstreamCompleted = true;
         ReactiveStreamsCompliance.TryCancel(subscription);
     }
     else
     {
         _upstream = subscription;
         // prefetch
         ReactiveStreamsCompliance.TryRequest(_upstream, _inputBuffer.Length);
     }
 }