コード例 #1
0
 public override void ReturnBuffer(byte[] buffer)
 {
     InternalBufferManager.PooledBufferManager.BufferPool pool = this.FindPool(buffer.Length);
     if (pool == null)
     {
         return;
     }
     if (buffer.Length != pool.BufferSize)
     {
         throw Fx.Exception.Argument(nameof(buffer), InternalSR.BufferIsNotRightSizeForBufferManager);
     }
     if (!pool.Return(buffer))
     {
         return;
     }
     pool.IncrementCount();
 }
コード例 #2
0
            private void ChangeQuota(ref InternalBufferManager.PooledBufferManager.BufferPool bufferPool, int delta)
            {
                InternalBufferManager.PooledBufferManager.BufferPool bufferPool1 = bufferPool;
                int limit = bufferPool1.Limit + delta;

                InternalBufferManager.PooledBufferManager.BufferPool pool = InternalBufferManager.PooledBufferManager.BufferPool.CreatePool(bufferPool1.BufferSize, limit);
                for (int index = 0; index < limit; ++index)
                {
                    byte[] buffer = bufferPool1.Take();
                    if (buffer != null)
                    {
                        pool.Return(buffer);
                        pool.IncrementCount();
                    }
                    else
                    {
                        break;
                    }
                }
                this.remainingMemory -= (long)(bufferPool1.BufferSize * delta);
                bufferPool            = pool;
            }