Ejemplo n.º 1
0
        private void CompleteRead()
        {
            var toCopy = _currentContentLength - _bytesReadInCurrentSegment;

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

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

            _bytesReadInCurrentSegment += toCopy;

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

            _readtcs.SetResult(toCopy);
        }
Ejemplo n.º 2
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.ReciveInternal();
                CompleteRead();
            }
        }
Ejemplo n.º 3
0
 public void Dispose()
 {
     _currentValue?.Dispose();
     _currentValue = null;
     if (_continuation != null)
     {
         _continuation();
     }
 }
Ejemplo n.º 4
0
        protected override void Dispose(bool disposing)
        {
            Flush(false);

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

            _currentOutputSegment.Dispose();
            _incommingSegments.Dispose();
        }
Ejemplo n.º 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.ReciveInternal();
                CompleteRead();
            }
        }