Esempio n. 1
0
        private void SeekBackward(int offset)
        {
            SimpleByteBufNode node = _node;

            int writeIndex = _writeIndex;
            int nextWrited = _nextWrited;
            int readIndex  = _readIndex - offset;

            while (readIndex < -1)
            {
                nextWrited += node.Used;

                node = node.Prev;

                writeIndex = node.Used;
                readIndex += writeIndex;
            }

            _node       = node;
            _nodeSize   = _node.Size;
            _data       = _node.Data;
            _writeIndex = writeIndex;
            _nextWrited = nextWrited;
            _readIndex  = readIndex;
        }
Esempio n. 2
0
        private void SeekForward(int offset)
        {
            SimpleByteBufNode node = _node;

            int writeIndex = _writeIndex;
            int nextWrited = _nextWrited;
            int readIndex  = _readIndex + offset;

            while (readIndex > writeIndex)
            {
                node = node.Next;
                int used = node.Used;

                readIndex -= writeIndex + 1;

                writeIndex  = used - 1;
                nextWrited -= used;
            }

            _node       = node;
            _nodeSize   = _node.Size;
            _data       = _node.Data;
            _writeIndex = writeIndex;
            _nextWrited = nextWrited;
            _readIndex  = readIndex;
        }
Esempio n. 3
0
        public override void Append(ByteBuf byteBuf)
        {
            var simpleByteBuf = (SimpleByteBuf)byteBuf;

            SimpleByteBufNode next = simpleByteBuf._node;

            _lastNode.Next = next;
            next.Prev      = _lastNode;

            _lastNode = simpleByteBuf._lastNode;

            _nextWrited += simpleByteBuf._nextWrited + next.Used;

            //_byteBufProvider.Release(simpleByteBuf);
        }
Esempio n. 4
0
        public void Attach(byte[] data, int size, int used)
        {
            SimpleByteBufNode node = new SimpleByteBufNode()
            {
                Data = data, Size = size, Used = used
            };

            _node     = node;
            _nodeSize = size;
            _data     = data;
            _lastNode = node;

            _writeIndex = used - 1;
            _nextWrited = 0;
            _readIndex  = -1;
            _released   = false;
        }
Esempio n. 5
0
        public override void ReleaseReaded()
        {
            return;

            SimpleByteBufNode prev = _node.Prev;

            // Отвязываем от текущего.
            _node.Prev = null;

            while (prev != null)
            {
                SimpleByteBufNode toRelease = prev;
                prev = prev.Prev;

                toRelease.Prev = null;
                toRelease.Next = null;

                //_byteBufProvider.Release(toRelease);
            }
        }
Esempio n. 6
0
        public override void Release()
        {
            return;

            ReleaseReaded();

            SimpleByteBufNode next = _node;

            while (next != null)
            {
                SimpleByteBufNode toRelease = next;
                next = next.Next;

                toRelease.Prev = null;
                toRelease.Next = null;

                //_byteBufProvider.Release(toRelease);
            }

            //_byteBufProvider.Release(this);
            _released = true;
        }