Home / Function/ shouldCreateTwoChunks() — netty Function Reference

shouldCreateTwoChunks() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  118435d9_3dd3_ca48_1376_b9a5efec9a1e["shouldCreateTwoChunks()"]
  f8855572_2abf_1bf6_a32b_5cf6d1cf4947["PooledByteBufAllocatorTest"]
  118435d9_3dd3_ca48_1376_b9a5efec9a1e -->|defined in| f8855572_2abf_1bf6_a32b_5cf6d1cf4947
  style 118435d9_3dd3_ca48_1376_b9a5efec9a1e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java lines 1018–1046

    @SuppressWarnings("Since15")
    @Test
    @EnabledForJreRange(min = JRE.JAVA_17) // RecordingStream
    @Timeout(10)
    public void shouldCreateTwoChunks() throws Exception {
        try (RecordingStream stream = new RecordingStream()) {
            final CountDownLatch eventsFlushed = new CountDownLatch(2);
            stream.enable(AllocateChunkEvent.class);
            stream.onEvent(AllocateChunkEvent.NAME,
                           event -> {
                                eventsFlushed.countDown();
                           });
            stream.startAsync();
            PooledByteBufAllocator allocator = newAllocator(false);
            int bufSize = 16896;
            int bufsToAllocate = 1 + allocator.metric().chunkSize() / bufSize;
            List<ByteBuf> buffers = new ArrayList<>(bufsToAllocate);
            for (int i = 0; i < bufsToAllocate; ++i) {
                buffers.add(allocator.heapBuffer(bufSize, bufSize));
            }
            // release all buffers
            for (ByteBuf buffer : buffers) {
                buffer.release();
            }
            buffers.clear();
            eventsFlushed.await();
            assertEquals(0, eventsFlushed.getCount());
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does shouldCreateTwoChunks() do?
shouldCreateTwoChunks() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java.
Where is shouldCreateTwoChunks() defined?
shouldCreateTwoChunks() is defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java at line 1018.

Analyze Your Own Codebase

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

Try Supermodel Free