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); }
void AllocateHuge(PooledArrayBuffer <T> buf, int reqCapacity) { PoolChunk <T> chunk = this.NewUnpooledChunk(reqCapacity); Interlocked.Add(ref this.activeBytesHuge, chunk.ChunkSize); buf.InitUnpooled(chunk, reqCapacity); Interlocked.Increment(ref this.allocationsHuge); }