shouldReuseTheSameChunk() — netty Function Reference
Architecture documentation for the shouldReuseTheSameChunk() function in AdaptiveByteBufAllocatorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD eec3917f_11d3_089b_d880_7f82ed0cde5d["shouldReuseTheSameChunk()"] b5780ec9_74a4_594b_4225_0099765d71e7["AdaptiveByteBufAllocatorTest"] eec3917f_11d3_089b_d880_7f82ed0cde5d -->|defined in| b5780ec9_74a4_594b_4225_0099765d71e7 style eec3917f_11d3_089b_d880_7f82ed0cde5d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java lines 280–313
@SuppressWarnings("Since15")
@Test
@EnabledForJreRange(min = JRE.JAVA_17) // RecordingStream
@Timeout(10)
public void shouldReuseTheSameChunk() throws Exception {
try (RecordingStream stream = new RecordingStream()) {
final CountDownLatch eventsFlushed = new CountDownLatch(1);
final AtomicInteger chunksAllocations = new AtomicInteger();
stream.enable(AllocateChunkEvent.class);
stream.onEvent(AllocateChunkEvent.NAME,
event -> {
chunksAllocations.incrementAndGet();
eventsFlushed.countDown();
});
stream.startAsync();
int bufSize = 16896;
ByteBufAllocator allocator = newAllocator(false);
List<ByteBuf> buffers = new ArrayList<>(32);
for (int i = 0; i < 30; ++i) {
buffers.add(allocator.heapBuffer(bufSize, bufSize));
}
// we still have 2 available segments in the chunk, so we should not allocate a new one
for (int i = 0; i < 128; ++i) {
allocator.heapBuffer(bufSize, bufSize).release();
}
// release all buffers
for (ByteBuf buffer : buffers) {
buffer.release();
}
buffers.clear();
eventsFlushed.await();
assertEquals(1, chunksAllocations.get());
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does shouldReuseTheSameChunk() do?
shouldReuseTheSameChunk() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java.
Where is shouldReuseTheSameChunk() defined?
shouldReuseTheSameChunk() is defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java at line 280.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free