示例#1
0
            private void ChangeQuota(ref BufferPool bufferPool, int delta)
            {
                if (TraceCore.BufferPoolChangeQuotaIsEnabled(Fx.Trace))
                {
                    TraceCore.BufferPoolChangeQuota(Fx.Trace, bufferPool.BufferSize, delta);
                }

                BufferPool oldBufferPool = bufferPool;
                int        newLimit      = oldBufferPool.Limit + delta;
                BufferPool newBufferPool = BufferPool.CreatePool(oldBufferPool.BufferSize, newLimit);

                for (int i = 0; i < newLimit; i++)
                {
                    byte[] buffer = oldBufferPool.Take();
                    if (buffer == null)
                    {
                        break;
                    }
                    newBufferPool.Return(buffer);
                    newBufferPool.IncrementCount();
                }
                _remainingMemory -= oldBufferPool.BufferSize * delta;
                bufferPool        = newBufferPool;
            }
示例#2
0
            private void ChangeQuota(ref InternalBufferManager.PooledBufferManager.BufferPool bufferPool, int delta)
            {
                if (TraceCore.BufferPoolChangeQuotaIsEnabled(Fx.Trace))
                {
                    TraceCore.BufferPoolChangeQuota(Fx.Trace, bufferPool.BufferSize, 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;
            }