Exemplo n.º 1
0
 private void RunReceiveProcess()
 {
     while (true)
     {
         if (_responsesQueue.TryDequeue(out _currentReceiveItem))
         {
             if (_pipelineException == null)
             {
                 if (_redisReceiver.Receive(_readArgs))
                 {
                     return;
                 }
                 ItemReceiveProcessDone(false, _readArgs);
             }
             else
             {
                 _currentReceiveItem.CallBack(_pipelineException, null);
             }
         }
         else
         {
             Interlocked.Exchange(ref _receiveIsRunning, 0);
             if (_responsesQueue.Count == 0 || Interlocked.CompareExchange(ref _receiveIsRunning, 1, 0) != 0)
             {
                 return;
             }
         }
     }
 }
Exemplo n.º 2
0
        public void ExecuteCommandAsync(byte[][] args, PipelineItem item)
        {
            if (_requestsQueue.Count > MaxQueueSize)
            {
                SpinWait.SpinUntil(() => _requestsQueue.Count < MaxQueueSize);
            }

            if (_pipelineException != null)
            {
                item.CallBack(_pipelineException, null);
            }
            else if (_pipelineIsInOneWayMode != 0 && !item.IsOneWay)
            {
                item.CallBack(new RedisException("Pipeline is in OneWay mode"), null);
            }
            else
            {
                _requestsQueue.Enqueue(item);
                TryStartSendProcess();
            }
        }
Exemplo n.º 3
0
        private void RunSendProcess()
        {
            while (true)
            {
                if (_requestsQueue.TryDequeue(out _currentSendItem))
                {
                    if (_pipelineException == null)
                    {
                        _sendArgs.DataToSend = _currentSendItem.Request;
                        if (_redisSender.Send(_sendArgs))
                        {
                            return;
                        }
                        ItemSendProcessDone(false, _sendArgs);
                    }
                    else
                    {
                        _currentSendItem.CallBack(_pipelineException, null);
                    }
                }
                else if (_redisSender.BytesInBuffer > 0 && _pipelineException == null)
                {
                    if (_redisSender.Flush(_flushChannelArgs))
                    {
                        return;
                    }
                    BufferFlushProcessDone(false, _flushChannelArgs);
                }
                else
                {
                    Interlocked.Exchange(ref _sendIsRunning, 0);

                    if (_requestsQueue.Count <= 0 || Interlocked.CompareExchange(ref _sendIsRunning, 1, 0) != 0)
                    {
                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void ExecuteCommandAsync(byte[][] args,PipelineItem item)
        {
            if (_requestsQueue.Count > MaxQueueSize)
                SpinWait.SpinUntil(() => _requestsQueue.Count < MaxQueueSize);

            if (_pipelineException != null)
                item.CallBack(_pipelineException, null);
            else if (_pipelineIsInOneWayMode != 0 && !item.IsOneWay)
                item.CallBack(new RedisException("Pipeline is in OneWay mode"), null);
            else
            {
                _requestsQueue.Enqueue(item);
                TryStartSendProcess();
            }
        }