コード例 #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
ファイル: RioStream.cs プロジェクト: cube3power/Cowboy
        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
ファイル: RioStream.cs プロジェクト: xela-trawets/RioSharp
        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
ファイル: SegmentAwaiter.cs プロジェクト: egb2000/CowboyTCP
 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
ファイル: RioStream.cs プロジェクト: xela-trawets/RioSharp
 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
ファイル: RioStream.cs プロジェクト: cube3power/RioSharp
        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();
 }