Exemple #1
0
        public PoolChunkList(PoolChunkList <T> nextList, int minUsage, int maxUsage, int chunkSize)
        {
            Contract.Assert(minUsage <= maxUsage);

            this.nextList    = nextList;
            this.minUsage    = minUsage;
            this.maxUsage    = maxUsage;
            this.maxCapacity = CalculateMaxCapacity(minUsage, chunkSize);
        }
Exemple #2
0
        internal PoolArena(
            PooledArrayBufferAllocator <T> parent,
            int pageSize,
            int maxOrder,
            int pageShifts,
            int chunkSize,
            int cacheAlignment)
        {
            this.Parent     = parent;
            this.PageSize   = pageSize;
            this.maxOrder   = maxOrder;
            this.PageShifts = pageShifts;
            this.ChunkSize  = chunkSize;
            this.DirectMemoryCacheAlignment     = cacheAlignment;
            this.DirectMemoryCacheAlignmentMask = cacheAlignment - 1;
            this.SubpageOverflowMask            = ~(pageSize - 1);
            this.tinySubpagePools = NewSubpagePoolArray(NumTinySubpagePools);
            for (int i = 0; i < this.tinySubpagePools.Length; i++)
            {
                this.tinySubpagePools[i] = NewSubpagePoolHead(pageSize);
            }

            this.NumSmallSubpagePools = pageShifts - 9;
            this.smallSubpagePools    = NewSubpagePoolArray(this.NumSmallSubpagePools);
            for (int i = 0; i < this.smallSubpagePools.Length; i++)
            {
                this.smallSubpagePools[i] = NewSubpagePoolHead(pageSize);
            }

            this.q100  = new PoolChunkList <T>(this, null, 100, int.MaxValue, chunkSize);
            this.q075  = new PoolChunkList <T>(this, this.q100, 75, 100, chunkSize);
            this.q050  = new PoolChunkList <T>(this, this.q075, 50, 100, chunkSize);
            this.q025  = new PoolChunkList <T>(this, this.q050, 25, 75, chunkSize);
            this.q000  = new PoolChunkList <T>(this, this.q025, 1, 50, chunkSize);
            this.qInit = new PoolChunkList <T>(this, this.q000, int.MinValue, 25, chunkSize);

            this.q100.PrevList(this.q075);
            this.q075.PrevList(this.q050);
            this.q050.PrevList(this.q025);
            this.q025.PrevList(this.q000);
            this.q000.PrevList(null);
            this.qInit.PrevList(this.qInit);

            this.ChunkLists = new ReadOnlyCollection <IPoolChunkListMetric>(
                new List <IPoolChunkListMetric>(6)
            {
                this.qInit,
                this.q000,
                this.q025,
                this.q050,
                this.q075,
                this.q100
            });
        }
Exemple #3
0
        // TODO: Test if adding padding helps under contention
        //private long pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;

        protected PoolArena(
            PooledByteBufferAllocator parent,
            int pageSize,
            int maxOrder,
            int pageShifts,
            int chunkSize)
        {
            this.Parent              = parent;
            this.PageSize            = pageSize;
            this.maxOrder            = maxOrder;
            this.PageShifts          = pageShifts;
            this.ChunkSize           = chunkSize;
            this.SubpageOverflowMask = ~(pageSize - 1);
            this.tinySubpagePools    = this.NewSubpagePoolArray(NumTinySubpagePools);
            for (int i = 0; i < this.tinySubpagePools.Length; i++)
            {
                this.tinySubpagePools[i] = this.NewSubpagePoolHead(pageSize);
            }

            this.NumSmallSubpagePools = pageShifts - 9;
            this.smallSubpagePools    = this.NewSubpagePoolArray(this.NumSmallSubpagePools);
            for (int i = 0; i < this.smallSubpagePools.Length; i++)
            {
                this.smallSubpagePools[i] = this.NewSubpagePoolHead(pageSize);
            }

            this.q100  = new PoolChunkList <T>(this, null, 100, int.MaxValue, chunkSize);
            this.q075  = new PoolChunkList <T>(this, this.q100, 75, 100, chunkSize);
            this.q050  = new PoolChunkList <T>(this, this.q075, 50, 100, chunkSize);
            this.q025  = new PoolChunkList <T>(this, this.q050, 25, 75, chunkSize);
            this.q000  = new PoolChunkList <T>(this, this.q025, 1, 50, chunkSize);
            this.qInit = new PoolChunkList <T>(this, this.q000, int.MinValue, 25, chunkSize);

            this.q100.PrevList(this.q075);
            this.q075.PrevList(this.q050);
            this.q050.PrevList(this.q025);
            this.q025.PrevList(this.q000);
            this.q000.PrevList(null);
            this.qInit.PrevList(this.qInit);

            var metrics = new List <IPoolChunkListMetric>(6);

            metrics.Add(this.qInit);
            metrics.Add(this.q000);
            metrics.Add(this.q025);
            metrics.Add(this.q050);
            metrics.Add(this.q075);
            metrics.Add(this.q100);
            this.chunkListMetrics = metrics;
        }
Exemple #4
0
 internal void PrevList(PoolChunkList <T> chunkList)
 {
     Contract.Requires(this.prevList == null);
     this.prevList = chunkList;
 }
Exemple #5
0
 internal void PrevList(PoolChunkList <T> list)
 {
     Debug.Assert(this.prevList == null);
     this.prevList = list;
 }