Home / Class/ SizeClassChunkController Class — netty Architecture

SizeClassChunkController Class — netty Architecture

Architecture documentation for the SizeClassChunkController class in AdaptivePoolingAllocator.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  13987726_678e_8e67_f858_dfa08f4414d6["SizeClassChunkController"]
  fee3fa6d_a7fb_30d6_ea34_49602c633a2c["AdaptivePoolingAllocator.java"]
  13987726_678e_8e67_f858_dfa08f4414d6 -->|defined in| fee3fa6d_a7fb_30d6_ea34_49602c633a2c
  303d1446_dfc2_4fe5_49d1_a180920e5841["SizeClassChunkController()"]
  13987726_678e_8e67_f858_dfa08f4414d6 -->|method| 303d1446_dfc2_4fe5_49d1_a180920e5841
  aeca1229_f28e_8b40_aaec_caeb646a7c3d["MpscIntQueue()"]
  13987726_678e_8e67_f858_dfa08f4414d6 -->|method| aeca1229_f28e_8b40_aaec_caeb646a7c3d
  b85e8f70_6197_62eb_5250_3fc80ff945d3["IntStack()"]
  13987726_678e_8e67_f858_dfa08f4414d6 -->|method| b85e8f70_6197_62eb_5250_3fc80ff945d3
  4c60941e_e0a0_70ab_d9ff_1197fdd8f8d6["computeBufferCapacity()"]
  13987726_678e_8e67_f858_dfa08f4414d6 -->|method| 4c60941e_e0a0_70ab_d9ff_1197fdd8f8d6
  d0801ddf_d578_d38b_f899_85d12408ceff["Chunk()"]
  13987726_678e_8e67_f858_dfa08f4414d6 -->|method| d0801ddf_d578_d38b_f899_85d12408ceff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java lines 686–740

    private static final class SizeClassChunkController implements ChunkController {

        private final ChunkAllocator chunkAllocator;
        private final int segmentSize;
        private final int chunkSize;
        private final ChunkRegistry chunkRegistry;

        private SizeClassChunkController(MagazineGroup group, int segmentSize, int chunkSize) {
            chunkAllocator = group.chunkAllocator;
            this.segmentSize = segmentSize;
            this.chunkSize = chunkSize;
            chunkRegistry = group.allocator.chunkRegistry;
        }

        private MpscIntQueue createEmptyFreeList() {
            return MpscIntQueue.create(chunkSize / segmentSize, SizeClassedChunk.FREE_LIST_EMPTY);
        }

        private MpscIntQueue createFreeList() {
            final int segmentsCount = chunkSize / segmentSize;
            final MpscIntQueue freeList = MpscIntQueue.create(segmentsCount, SizeClassedChunk.FREE_LIST_EMPTY);
            int segmentOffset = 0;
            for (int i = 0; i < segmentsCount; i++) {
                freeList.offer(segmentOffset);
                segmentOffset += segmentSize;
            }
            return freeList;
        }

        private IntStack createLocalFreeList() {
            final int segmentsCount = chunkSize / segmentSize;
            int segmentOffset = chunkSize;
            int[] offsets = new int[segmentsCount];
            for (int i = 0; i < segmentsCount; i++) {
                segmentOffset -= segmentSize;
                offsets[i] = segmentOffset;
            }
            return new IntStack(offsets);
        }

        @Override
        public int computeBufferCapacity(
                int requestedSize, int maxCapacity, boolean isReallocation) {
            return Math.min(segmentSize, maxCapacity);
        }

        @Override
        public Chunk newChunkAllocation(int promptingSize, Magazine magazine) {
            AbstractByteBuf chunkBuffer = chunkAllocator.allocate(chunkSize, chunkSize);
            assert chunkBuffer.capacity() == chunkSize;
            SizeClassedChunk chunk = new SizeClassedChunk(chunkBuffer, magazine, this);
            chunkRegistry.add(chunk);
            return chunk;
        }
    }

Frequently Asked Questions

What is the SizeClassChunkController class?
SizeClassChunkController is a class in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java.
Where is SizeClassChunkController defined?
SizeClassChunkController is defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java at line 686.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free