Пример #1
0
        // TODO: Test if adding padding helps under contention
        //private long pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;

        public PoolChunkList(PoolArena <T> arena, PoolChunkList <T> nextList, int minUsage, int maxUsage, int chunkSize)
        {
            Contract.Assert(minUsage <= maxUsage);
            this.arena       = arena;
            this.nextList    = nextList;
            this.minUsage    = minUsage;
            this.maxUsage    = maxUsage;
            this.maxCapacity = CalculateMaxCapacity(minUsage, chunkSize);
        }
Пример #2
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;
        }
Пример #3
0
 internal void PrevList(PoolChunkList <T> list)
 {
     Debug.Assert(this.prevList == null);
     this.prevList = list;
 }