示例#1
0
        public IByteBuffer Take()
        {
            ByteBufferSlab slab = _slab.Take(0);

            if (slab == null)
            {
                //We need to copy :(
                var dest = new byte[Count];
                Array.Copy(_segment.Array, _segment.Offset + _position, dest, 0, dest.Length);
                return(ByteBufferArray.FromBufferData(dest, 0, dest.Length));
            }

            int cStart = slab.Start;
            int cEnd   = slab.End;
            ArraySegment <byte> cSegment = slab.Segment;

            slab.Start   = Start;
            slab.End     = End;
            slab.Segment = Segment;

            Start   = cStart;
            End     = cEnd; //Should always be 0
            Segment = cSegment;

            return(slab);
        }
示例#2
0
        public IByteBuffer Take()
        {
            var tempBuffer2 = new ByteBufferArray();

            byte[] data  = Data;
            int    start = Start;
            int    end   = End;

            Data  = tempBuffer2.Data;
            Start = tempBuffer2.Start;
            End   = tempBuffer2.End;

            tempBuffer2.Data  = data;
            tempBuffer2.Start = start;
            tempBuffer2.End   = end;

            return(tempBuffer2);
        }
示例#3
0
        public IByteBuffer Take()
        {
            var tempBuffer2 = new ByteBufferArray();
            byte[] data = Data;
            int start = Start;
            int end = End;

            Data = tempBuffer2.Data;
            Start = tempBuffer2.Start;
            End = tempBuffer2.End;

            tempBuffer2.Data = data;
            tempBuffer2.Start = start;
            tempBuffer2.End = end;

            return tempBuffer2;
        }