コード例 #1
0
        public override Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            Interlocked.Increment(ref pendingreads);

            if (pendingreads > 1)
            {
            }
            _readBuffer = buffer;
            _readoffset = offset;
            _readCount  = count;

            if (_currentContentLength == _bytesReadInCurrentSegment)
            {
                if (_nextInputSegment.IsCompleted)
                {
                    return(Task.FromResult(GetNewSegment()));
                }
                else
                {
                    _readtcs = new TaskCompletionSource <int>();
                    _nextInputSegment.OnCompleted(_getNewSegmentDelegateDelegate);
                    return(_readtcs.Task);
                }
            }
            else
            {
                return(Task.FromResult(CompleteRead()));
            }
        }
コード例 #2
0
        void CompleteRead()
        {
            var tmp = _currentInputSegment;

            _currentInputSegment = _nextInputSegment;
            _currentInputSegment.GetResult();
            _nextInputSegment = tmp;
            if (_currentInputSegment.CurrentContentLength != 0)
            {
                _socket.BeginReceive(_nextInputSegment);
            }

            OnIncommingSegment(_currentInputSegment);

            if (_currentInputSegment.CurrentContentLength != 0)
            {
                if (_nextInputSegment.IsCompleted)
                {
                    CompleteRead();
                }
                else
                {
                    _nextInputSegment.OnCompleted(completeReadDelegate);
                }
            }
            else
            {
                Dispose();
            }
        }
コード例 #3
0
ファイル: RioSegmentReader.cs プロジェクト: aL3891/RioSharp
        public void Start()
        {
            _nextInputSegment = _nextInputSegment ?? _socket.ReceiveBufferPool.GetBuffer();
            _currentInputSegment = _currentInputSegment ?? _socket.ReceiveBufferPool.GetBuffer();
            _socket.BeginReceive(_nextInputSegment);

            if (_nextInputSegment.IsCompleted)
                CompleteRead();
            else
                _nextInputSegment.OnCompleted(completeReadDelegate);
        }
コード例 #4
0
        public void Start()
        {
            _socket.BeginReceive(_nextInputSegment);

            if (_nextInputSegment.IsCompleted)
            {
                CompleteRead();
            }
            else
            {
                _nextInputSegment.OnCompleted(completeReadDelegate);
            }
        }
コード例 #5
0
        public void Start()
        {
            _nextInputSegment    = _nextInputSegment ?? _socket.ReceiveBufferPool.GetBuffer();
            _currentInputSegment = _currentInputSegment ?? _socket.ReceiveBufferPool.GetBuffer();
            _socket.BeginReceive(_nextInputSegment);

            if (_nextInputSegment.IsCompleted)
            {
                CompleteRead();
            }
            else
            {
                _nextInputSegment.OnCompleted(completeReadDelegate);
            }
        }
コード例 #6
0
        public void CompleteRead()
        {
            var tmp = _currentInputSegment;
            _currentInputSegment = _nextInputSegment;
            _nextInputSegment = tmp;

            _socket.BeginReceive(_nextInputSegment);

            OnIncommingSegment(_currentInputSegment);

            if (_nextInputSegment.IsCompleted)
                CompleteRead();
            else
                _nextInputSegment.OnCompleted(completeReadDelegate);
        }
コード例 #7
0
        public void CompleteRead()
        {
            var tmp = _currentInputSegment;

            _currentInputSegment = _nextInputSegment;
            _nextInputSegment    = tmp;

            _socket.BeginReceive(_nextInputSegment);

            OnIncommingSegment(_currentInputSegment);

            if (_nextInputSegment.IsCompleted)
            {
                CompleteRead();
            }
            else
            {
                _nextInputSegment.OnCompleted(completeReadDelegate);
            }
        }
コード例 #8
0
ファイル: RioStream.cs プロジェクト: cube3power/RioSharp
        public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            _readBuffer = buffer;
            _readoffset = offset;
            _readCount = count;

            if (_currentContentLength == _bytesReadInCurrentSegment)
            {
                if (_nextInputSegment.IsCompleted)
                    return Task.FromResult(GetNewSegment());
                else
                {
                    _readtcs = new TaskCompletionSource<int>();
                    _nextInputSegment.OnCompleted(_getNewSegmentDelegateDelegate);
                    return _readtcs.Task;
                }
            }
            else
                return Task.FromResult(CompleteRead());

        }
コード例 #9
0
ファイル: RioSegmentReader.cs プロジェクト: aL3891/RioSharp
        void CompleteRead()
        {
            var tmp = _currentInputSegment;
            _currentInputSegment = _nextInputSegment;
            _currentInputSegment.GetResult();
            _nextInputSegment = tmp;
            if (_currentInputSegment.CurrentContentLength != 0)
                _socket.BeginReceive(_nextInputSegment);

            OnIncommingSegment(_currentInputSegment);

            if (_currentInputSegment.CurrentContentLength != 0)
            {
                if (_nextInputSegment.IsCompleted)
                    CompleteRead();
                else
                    _nextInputSegment.OnCompleted(completeReadDelegate);
            }
            else {
                Dispose();
            }
        }