void InitBufWithSubpage(PooledByteBuffer <T> buf, long handle, int bitmapIdx, int reqCapacity) { Contract.Assert(bitmapIdx != 0); int memoryMapIdx = MemoryMapIdx(handle); PoolSubpage <T> subpage = this.subpages[this.SubpageIdx(memoryMapIdx)]; Contract.Assert(subpage.DoNotDestroy); Contract.Assert(reqCapacity <= subpage.ElemSize); buf.Init( this, handle, this.RunOffset(memoryMapIdx) + (bitmapIdx & 0x3FFFFFFF) * subpage.ElemSize + this.Offset, reqCapacity, subpage.ElemSize, this.Arena.Parent.ThreadCache <T>()); }
internal void InitBuf(PooledByteBuffer <T> buf, long handle, int reqCapacity) { int memoryMapIdx = MemoryMapIdx(handle); int bitmapIdx = BitmapIdx(handle); if (bitmapIdx == 0) { sbyte val = this.Value(memoryMapIdx); Debug.Assert(val == this.unusable, val.ToString()); buf.Init(this, handle, this.RunOffset(memoryMapIdx) + this.Offset, reqCapacity, this.RunLength(memoryMapIdx), this.Arena.Parent.ThreadCache <T>()); } else { this.InitBufWithSubpage(buf, handle, bitmapIdx, reqCapacity); } }