void AllocateNormal(PooledArrayBuffer <T> buf, int reqCapacity, int normCapacity) { lock (this) { if (this.q050.Allocate(buf, reqCapacity, normCapacity) || this.q025.Allocate(buf, reqCapacity, normCapacity) || this.q000.Allocate(buf, reqCapacity, normCapacity) || this.qInit.Allocate(buf, reqCapacity, normCapacity) || this.q075.Allocate(buf, reqCapacity, normCapacity)) { ++this.allocationsNormal; return; } if (this.chunkCount < this.maxChunkCount) { // Add a new chunk. PoolChunk <T> c = this.NewChunk(this.PageSize, this.maxOrder, this.PageShifts, this.ChunkSize); this.chunkCount++; long handle = c.Allocate(normCapacity); ++this.allocationsNormal; Contract.Assert(handle > 0); c.InitBuf(buf, handle, reqCapacity); this.qInit.Add(c); return; } } PoolChunk <T> chunk = this.NewUnpooledChunk(reqCapacity, false); buf.InitUnpooled(chunk, reqCapacity); Interlocked.Increment(ref this.allocationsNormal); }
internal bool Allocate(PooledArrayBuffer <T> buf, int reqCapacity, int normCapacity) { if (this.head == null || normCapacity > this.maxCapacity) { // Either this PoolChunkList is empty or the requested capacity is larger then the capacity which can // be handled by the PoolChunks that are contained in this PoolChunkList. return(false); } for (PoolChunk <T> cur = this.head; ;) { long handle = cur.Allocate(normCapacity); if (handle < 0) { cur = cur.Next; if (cur == null) { return(false); } } else { cur.InitBuf(buf, handle, reqCapacity); if (cur.Usage >= this.maxUsage) { this.Remove(cur); this.nextList.Add(cur); } return(true); } } }
void AllocateNormal(PooledByteBuffer <T> buf, int reqCapacity, int normCapacity) { if (this.q050.Allocate(buf, reqCapacity, normCapacity) || this.q025.Allocate(buf, reqCapacity, normCapacity) || this.q000.Allocate(buf, reqCapacity, normCapacity) || this.qInit.Allocate(buf, reqCapacity, normCapacity) || this.q075.Allocate(buf, reqCapacity, normCapacity)) { return; } // Add a new chunk. PoolChunk <T> c = this.NewChunk(this.PageSize, this.maxOrder, this.PageShifts, this.ChunkSize); long handle = c.Allocate(normCapacity); Debug.Assert(handle > 0); c.InitBuf(buf, handle, reqCapacity); this.qInit.Add(c); }
void AllocateNormal(PooledArrayBuffer <T> buf, int reqCapacity, int normCapacity) { lock (this) { if (this.q050.Allocate(buf, reqCapacity, normCapacity) || this.q025.Allocate(buf, reqCapacity, normCapacity) || this.q000.Allocate(buf, reqCapacity, normCapacity) || this.qInit.Allocate(buf, reqCapacity, normCapacity) || this.q075.Allocate(buf, reqCapacity, normCapacity)) { ++this.NumNormalAllocations; return; } // Add a new chunk. PoolChunk <T> c = this.NewChunk(this.PageSize, this.maxOrder, this.PageShifts, this.ChunkSize); long handle = c.Allocate(normCapacity); ++this.NumNormalAllocations; Contract.Assert(handle > 0); c.InitBuf(buf, handle, reqCapacity); this.qInit.Add(c); } }
protected override void InitBuf( PoolChunk <T> chunk, long handle, PooledArrayBuffer <T> buf, int reqCapacity) => chunk.InitBuf(buf, handle, reqCapacity);