/// <summary>
 /// 
 /// </summary>
 /// <param name="buffer">����ArrayBuffer</param>
 /// <param name="offset">buffer�е���ʼλ��</param>
 /// <param name="length">���ݳ���</param>
 /// <param name="id">���</param>
 public BufferSegment(ArrayBuffer buffer, int offset, int length, int id)
 {
     Buffer = buffer;
     Offset = offset;
     Length = length;
     Number = id;
 }
        /// <summary>
        /// Creates a new buffer and adds the segments to the buffer pool.
        /// </summary>
        private void CreateBuffer()
        {
            // create a new buffer
            var newBuf = new ArrayBuffer(this, _segmentCount * _segmentSize);

            // create segments from the buffer
            for (int i = 0; i < _segmentCount; i++) {
                _availableSegments.Enqueue(new BufferSegment(newBuf, i * _segmentSize, _segmentSize, _segmentId++));
            }

            // increment our total count
            _totalSegmentCount += _segmentCount;

            // hold a ref to our new buffer
            _buffers.Add(newBuf);

            // update global alloc'd memory
            Interlocked.Add(ref GlobalAllocatedMemory, _segmentCount * _segmentSize);
        }