Example #1
0
        public void Append(ReadIterator begin, ReadIterator end)
        {
            var clonedBegin = MemoryBlockSegment.Clone(begin, end);
            var clonedEnd   = clonedBegin;

            while (clonedEnd.Next != null)
            {
                clonedEnd = clonedEnd.Next;
            }

            if (_tail == null)
            {
                _head      = clonedBegin;
                _headIndex = clonedBegin.Start;
            }
            else
            {
                Debug.Assert(_tail.Block != null);
                Debug.Assert(_tail.Next == null);
                Debug.Assert(_tail.End == _tailIndex);

                _tail.Next = clonedBegin;
            }

            _tail      = clonedEnd;
            _tailIndex = clonedEnd.End;
        }
Example #2
0
        public ReadableBuffer Clone()
        {
            var begin = _start;
            var end   = _end;

            var segmentHead = MemoryBlockSegment.Clone(begin, end);
            var segmentTail = segmentHead;

            while (segmentTail.Next != null)
            {
                segmentTail = segmentTail.Next;
            }

            begin = new ReadIterator(segmentHead);
            end   = new ReadIterator(segmentTail, segmentTail.End);

            return(new ReadableBuffer(begin, end, isOwner: true));
        }
Example #3
0
        private ReadableBuffer(ref ReadableBuffer buffer)
        {
            _channel = buffer._channel;

            var begin = buffer._start;
            var end   = buffer._end;

            MemoryBlockSegment segmentTail;
            var segmentHead = MemoryBlockSegment.Clone(begin, end, out segmentTail);

            begin = new ReadCursor(segmentHead);
            end   = new ReadCursor(segmentTail, segmentTail.End);

            _start   = begin;
            _end     = end;
            _isOwner = true;
            _span    = buffer._span;

            _length = buffer._length;
        }
Example #4
0
        public void Append(ref ReadableBuffer buffer)
        {
            MemoryBlockSegment clonedEnd;
            var clonedBegin = MemoryBlockSegment.Clone(buffer.Start, buffer.End, out clonedEnd);

            if (_tail == null)
            {
                _head      = clonedBegin;
                _headIndex = clonedBegin.Start;
            }
            else
            {
                Debug.Assert(_tail.Block != null);
                Debug.Assert(_tail.Next == null);
                Debug.Assert(_tail.End == _tailIndex);

                _tail.Next = clonedBegin;
            }

            _tail      = clonedEnd;
            _tailIndex = clonedEnd.End;
        }