示例#1
0
        int _largeAllocationCounter; // performance counter for non-pooled allocations

        private BufferPool(int maxBufferSize)
        {
            Precondition.Require(maxBufferSize > 0);

            _maxBufferSize = maxBufferSize;

            var maxSizeBin = SelectBinIndex(maxBufferSize);

            _bins = new BufferBin[maxSizeBin + 1];

            for (var binIndex = 0; binIndex < _bins.Length; binIndex++)
            {
                int maxSizeForBin = GetMaxSizeForBin(binIndex);
                _bins[binIndex] = new BufferBin(maxSizeForBin, 10);
            }
        }
示例#2
0
        int _maxBufferSize; // larger buffers won't be pooled

        #endregion Fields

        #region Constructors

        private BufferPool(int maxBufferSize)
        {
            Precondition.Require(maxBufferSize > 0);

            _maxBufferSize = maxBufferSize;

            var maxSizeBin = SelectBinIndex(maxBufferSize);
            _bins = new BufferBin[maxSizeBin + 1];

            for (var binIndex = 0; binIndex < _bins.Length; binIndex++)
            {
                int maxSizeForBin = GetMaxSizeForBin(binIndex);
                _bins[binIndex] = new BufferBin(maxSizeForBin, 10);
            }
        }