public override byte[] TakeBuffer(int bufferSize) { Fx.Assert(bufferSize >= 0, "caller must ensure a non-negative argument"); BufferPool bufferPool = FindPool(bufferSize); byte[] returnValue; if (bufferPool != null) { byte[] buffer = bufferPool.Take(); if (buffer != null) { bufferPool.DecrementCount(); returnValue = buffer; } else { if (bufferPool.Peak == bufferPool.Limit) { bufferPool.Misses++; if (++totalMisses >= maxMissesBeforeTuning) { TuneQuotas(); } } //if (TraceCore.BufferPoolAllocationIsEnabled(Fx.Trace)) //{ // TraceCore.BufferPoolAllocation(Fx.Trace, bufferPool.BufferSize); //} returnValue = Fx.AllocateByteArray(bufferPool.BufferSize); } } else { //if (TraceCore.BufferPoolAllocationIsEnabled(Fx.Trace)) //{ // TraceCore.BufferPoolAllocation(Fx.Trace, bufferSize); //} returnValue = Fx.AllocateByteArray(bufferSize); } return(returnValue); }
public override byte[] TakeBuffer(int bufferSize) { return(Fx.AllocateByteArray(bufferSize)); }