Home / Function/ PoolChunkList() — netty Function Reference

PoolChunkList() — netty Function Reference

Architecture documentation for the PoolChunkList() function in PoolChunkList.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  e6307482_2181_2668_7240_5899f12f023b["PoolChunkList()"]
  ad035c77_35f5_72ad_c059_f20a84e5fef2["PoolChunkList"]
  e6307482_2181_2668_7240_5899f12f023b -->|defined in| ad035c77_35f5_72ad_c059_f20a84e5fef2
  3c6adea5_3b63_3b6c_a0b5_fba34459afae["calculateMaxCapacity()"]
  e6307482_2181_2668_7240_5899f12f023b -->|calls| 3c6adea5_3b63_3b6c_a0b5_fba34459afae
  style e6307482_2181_2668_7240_5899f12f023b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/PoolChunkList.java lines 47–72

    PoolChunkList(PoolArena<T> arena, PoolChunkList<T> nextList, int minUsage, int maxUsage, int chunkSize) {
        assert minUsage <= maxUsage;
        this.arena = arena;
        this.nextList = nextList;
        this.minUsage = minUsage;
        this.maxUsage = maxUsage;
        maxCapacity = calculateMaxCapacity(minUsage, chunkSize);

        // the thresholds are aligned with PoolChunk.usage() logic:
        // 1) basic logic: usage() = 100 - freeBytes * 100L / chunkSize
        //    so, for example: (usage() >= maxUsage) condition can be transformed in the following way:
        //      100 - freeBytes * 100L / chunkSize >= maxUsage
        //      freeBytes <= chunkSize * (100 - maxUsage) / 100
        //      let freeMinThreshold = chunkSize * (100 - maxUsage) / 100, then freeBytes <= freeMinThreshold
        //
        //  2) usage() returns an int value and has a floor rounding during a calculation,
        //     to be aligned absolute thresholds should be shifted for "the rounding step":
        //       freeBytes * 100 / chunkSize < 1
        //       the condition can be converted to: freeBytes < 1 * chunkSize / 100
        //     this is why we have + 0.99999999 shifts. A example why just +1 shift cannot be used:
        //       freeBytes = 16777216 == freeMaxThreshold: 16777216, usage = 0 < minUsage: 1, chunkSize: 16777216
        //     At the same time we want to have zero thresholds in case of (maxUsage == 100) and (minUsage == 100).
        //
        freeMinThreshold = (maxUsage == 100) ? 0 : (int) (chunkSize * (100.0 - maxUsage + 0.99999999) / 100L);
        freeMaxThreshold = (minUsage == 100) ? 0 : (int) (chunkSize * (100.0 - minUsage + 0.99999999) / 100L);
    }

Domain

Subdomains

Frequently Asked Questions

What does PoolChunkList() do?
PoolChunkList() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/PoolChunkList.java.
Where is PoolChunkList() defined?
PoolChunkList() is defined in buffer/src/main/java/io/netty/buffer/PoolChunkList.java at line 47.
What does PoolChunkList() call?
PoolChunkList() calls 1 function(s): calculateMaxCapacity.

Analyze Your Own Codebase

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

Try Supermodel Free