AdaptiveByteBuf() — netty Function Reference
Architecture documentation for the AdaptiveByteBuf() function in AdaptivePoolingAllocator.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 080309e4_d57c_ce66_6f51_f105cc6f6710["AdaptiveByteBuf()"] 5c7d3ca5_8d2c_76d2_0628_1864f492365d["MagazineGroup"] 080309e4_d57c_ce66_6f51_f105cc6f6710 -->|defined in| 5c7d3ca5_8d2c_76d2_0628_1864f492365d b550a3a7_b98a_e36b_d58d_413aa6587ed4["allocate()"] 080309e4_d57c_ce66_6f51_f105cc6f6710 -->|calls| b550a3a7_b98a_e36b_d58d_413aa6587ed4 4a58da3c_40d1_32f5_6976_57fdd64dc888["tryAllocate()"] 080309e4_d57c_ce66_6f51_f105cc6f6710 -->|calls| 4a58da3c_40d1_32f5_6976_57fdd64dc888 7d98a725_7e43_8a22_908d_604424cb35a1["tryExpandMagazines()"] 080309e4_d57c_ce66_6f51_f105cc6f6710 -->|calls| 7d98a725_7e43_8a22_908d_604424cb35a1 59c1d0ae_e507_0c96_51fa_359fe1b6411f["release()"] 080309e4_d57c_ce66_6f51_f105cc6f6710 -->|calls| 59c1d0ae_e507_0c96_51fa_359fe1b6411f style 080309e4_d57c_ce66_6f51_f105cc6f6710 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java lines 393–433
public AdaptiveByteBuf allocate(int size, int maxCapacity, Thread currentThread, AdaptiveByteBuf buf) {
boolean reallocate = buf != null;
// Path for thread-local allocation.
Magazine tlMag = threadLocalMagazine;
if (tlMag != null) {
if (buf == null) {
buf = tlMag.newBuffer();
}
boolean allocated = tlMag.tryAllocate(size, maxCapacity, buf, reallocate);
assert allocated : "Allocation of threadLocalMagazine must always succeed";
return buf;
}
// Path for concurrent allocation.
long threadId = currentThread.getId();
Magazine[] mags;
int expansions = 0;
do {
mags = magazines;
int mask = mags.length - 1;
int index = (int) (threadId & mask);
for (int i = 0, m = mags.length << 1; i < m; i++) {
Magazine mag = mags[index + i & mask];
if (buf == null) {
buf = mag.newBuffer();
}
if (mag.tryAllocate(size, maxCapacity, buf, reallocate)) {
// Was able to allocate.
return buf;
}
}
expansions++;
} while (expansions <= EXPANSION_ATTEMPTS && tryExpandMagazines(mags.length));
// The magazines failed us; contention too high and we don't want to spend more effort expanding the array.
if (!reallocate && buf != null) {
buf.release(); // Release the previously claimed buffer before we return.
}
return null;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does AdaptiveByteBuf() do?
AdaptiveByteBuf() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java.
Where is AdaptiveByteBuf() defined?
AdaptiveByteBuf() is defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java at line 393.
What does AdaptiveByteBuf() call?
AdaptiveByteBuf() calls 4 function(s): allocate, release, tryAllocate, tryExpandMagazines.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free