Пример #1
0
 void Flush(bool disposing)
 {
     if (_remainingSpaceInOutputSegment == 0)
     {
         _socket.Flush();
     }
     else if (_remainingSpaceInOutputSegment == _outputSegmentTotalLength)
     {
         if (disposing)
         {
             _currentOutputSegment.Dispose();
         }
     }
     else
     {
         unsafe
         {
             _currentOutputSegment.SegmentPointer->Length = _outputSegmentTotalLength - _remainingSpaceInOutputSegment;
         }
         _socket.Send(_currentOutputSegment, RIO_SEND_FLAGS.NONE);
         _currentOutputSegment.Dispose();
         if (disposing)
         {
             _remainingSpaceInOutputSegment = 0;
             _outputSegmentTotalLength      = 0;
         }
         else
         {
             _currentOutputSegment          = _socket.SendBufferPool.GetBuffer();
             _outputSegmentTotalLength      = _currentOutputSegment.TotalLength;
             _remainingSpaceInOutputSegment = _outputSegmentTotalLength;
         }
     }
 }
Пример #2
0
        private void CompleteRead()
        {
            var toCopy = _currentContentLength - _bytesReadInCurrentSegment;

            if (toCopy > _readCount)
            {
                toCopy = _readCount;
            }

            unsafe
            {
                fixed(byte *p = &_readBuffer[_readoffset])
                Buffer.MemoryCopy(_currentInputSegment.RawPointer + _bytesReadInCurrentSegment, p, _readCount, toCopy);
            }

            _bytesReadInCurrentSegment += toCopy;

            if (_currentContentLength == _bytesReadInCurrentSegment)
            {
                _currentInputSegment.Dispose();
                _currentInputSegment = null;
            }

            _readtcs.SetResult(toCopy);
        }
Пример #3
0
        private void GetNewSegment()
        {
            _currentInputSegment = _incommingSegments.GetResult();
            if (_currentInputSegment == null)
            {
                _readtcs.SetResult(0);
                return;
            }

            _bytesReadInCurrentSegment = 0;
            _currentContentLength = _currentInputSegment.CurrentContentLength;

            if (_currentContentLength == 0)
            {
                _currentInputSegment.Dispose();
                _currentInputSegment = null;
                _readtcs.SetResult(0);
                return;
            }
            else
            {
                _socket.BeginReceive();
                CompleteRead();
            }
        }
Пример #4
0
        protected override void Dispose(bool disposing)
        {
            Flush(false);

            _nextInputSegment?.Dispose();
            _currentInputSegment?.Dispose();
        }
Пример #5
0
        private void GetNewSegment()
        {
            _currentInputSegment = _incommingSegments.GetResult();
            if (_currentInputSegment == null)
            {
                _readtcs.SetResult(0);
                return;
            }

            _bytesReadInCurrentSegment = 0;
            _currentContentLength      = _currentInputSegment.CurrentContentLength;

            if (_currentContentLength == 0)
            {
                _currentInputSegment.Dispose();
                _currentInputSegment = null;
                _readtcs.SetResult(0);
                return;
            }
            else
            {
                _socket.BeginReceive();
                CompleteRead();
            }
        }
Пример #6
0
 public void Dispose()
 {
     _currentValue?.Dispose();
     _currentValue = null;
     if (_continuation != null)
     {
         _continuation();
     }
 }
Пример #7
0
        protected override void Dispose(bool disposing)
        {
            if (this.disposing)
            {
                return;
            }
            this.disposing = true;

            Flush(true);
            _nextInputSegment?.Dispose();
            _currentInputSegment?.Dispose();
        }
Пример #8
0
        protected override void Dispose(bool disposing)
        {
            Flush(false);

            if (_currentInputSegment != null)
            {
                _currentInputSegment.Dispose();
            }

            _currentOutputSegment.Dispose();
            _incommingSegments.Dispose();
        }
Пример #9
0
 int GetNewSegment()
 {
     if (_nextInputSegment.CurrentContentLength == 0)
     {
         _nextInputSegment.Dispose();
         _currentInputSegment.Dispose();
         return(0);
     }
     else
     {
         _bytesReadInCurrentSegment = 0;
         _nextInputSegment          = _socket.BeginReceive(Interlocked.Exchange(ref _currentInputSegment, _nextInputSegment));
         return(CompleteRead());
     }
 }
Пример #10
0
        private int GetNewSegment()
        {
            var tmp = _currentInputSegment;
            _nextInputSegment.GetResult();
            _currentInputSegment = _nextInputSegment;

            _bytesReadInCurrentSegment = 0;
            _currentContentLength = _currentInputSegment.CurrentContentLength;

            if (_currentContentLength == 0)
            {
                _currentInputSegment.Dispose();
                tmp.Dispose();
                return 0;
            }
            else
            {
                _nextInputSegment = tmp;
                _socket.BeginReceive(_nextInputSegment);
                return CompleteRead();
            }
        }
Пример #11
0
 public void Dispose()
 {
     _nextInputSegment.Dispose();
     _currentInputSegment.Dispose();
 }