ServerToolkit.BufferManagement.BufferPool.BufferPool C# (CSharp) Method

BufferPool() public method

Initializes a new instance of the BufferPool class
public BufferPool ( long slabSize, int initialSlabs, int subsequentSlabs ) : System
slabSize long Length, in bytes, of a slab in the BufferPool
initialSlabs int Number of slabs to create initially
subsequentSlabs int Number of additional slabs to create at a time
return System
        public BufferPool(long slabSize, int initialSlabs, int subsequentSlabs)
        {
            if (slabSize < 1) throw new ArgumentException("slabSize must be equal to or greater than 1");
            if (initialSlabs < 1) throw new ArgumentException("initialSlabs must be equal to or greater than 1");
            if (subsequentSlabs < 1) throw new ArgumentException("subsequentSlabs must be equal to or greater than 1");
            if (slabSize > MaximumSlabSize) throw new ArgumentException("slabSize cannot be larger BufferPool.MaximumSlabSize");

            this.slabSize = slabSize > MinimumSlabSize ? slabSize : MinimumSlabSize;
            this.initialSlabs = initialSlabs;
            this.subsequentSlabs = subsequentSlabs;

            // lock is unnecessary in this instance constructor
            //lock (syncSlabList)
            //{
                if (slabs.Count == 0)
                {
                    SetSingleSlabPool(initialSlabs == 1); //Assume for optimization reasons that it's a single slab pool if the number of initial slabs is 1

                    for (int i = 0; i < initialSlabs; i++)
                    {
                        slabs.Add(new MemorySlab(slabSize, this));
                    }

                    firstSlab = slabs[0];
                }
            //}
        }