public override void ReturnBuffer(byte[] buffer) { InternalBufferManager.PooledBufferManager.BufferPool bufferPool = this.FindPool((int)buffer.Length); if (bufferPool != null) { if ((int)buffer.Length != bufferPool.BufferSize) { throw Fx.Exception.Argument("buffer", SRCore.BufferIsNotRightSizeForBufferManager); } if (bufferPool.Return(buffer)) { bufferPool.IncrementCount(); } } }
private void ChangeQuota(ref InternalBufferManager.PooledBufferManager.BufferPool bufferPool, int delta) { InternalBufferManager.PooledBufferManager.BufferPool bufferPool1 = bufferPool; int limit = bufferPool1.Limit + delta; InternalBufferManager.PooledBufferManager.BufferPool bufferPool2 = InternalBufferManager.PooledBufferManager.BufferPool.CreatePool(bufferPool1.BufferSize, limit); for (int i = 0; i < limit; i++) { byte[] numArray = bufferPool1.Take(); if (numArray == null) { break; } bufferPool2.Return(numArray); bufferPool2.IncrementCount(); } InternalBufferManager.PooledBufferManager bufferSize = this; bufferSize.remainingMemory = bufferSize.remainingMemory - (long)(bufferPool1.BufferSize * delta); bufferPool = bufferPool2; }