Home / Function/ jfrBufferAllocationThreadLocal() — netty Function Reference

jfrBufferAllocationThreadLocal() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  9c0171d1_e95a_5c33_7c50_1e92768136a1["jfrBufferAllocationThreadLocal()"]
  b5780ec9_74a4_594b_4225_0099765d71e7["AdaptiveByteBufAllocatorTest"]
  9c0171d1_e95a_5c33_7c50_1e92768136a1 -->|defined in| b5780ec9_74a4_594b_4225_0099765d71e7
  f95f6269_707a_cb2d_e5c5_1293cb0ec01f["AdaptiveByteBufAllocator()"]
  9c0171d1_e95a_5c33_7c50_1e92768136a1 -->|calls| f95f6269_707a_cb2d_e5c5_1293cb0ec01f
  style 9c0171d1_e95a_5c33_7c50_1e92768136a1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java lines 349–393

    @SuppressWarnings("Since15")
    @Test
    @EnabledForJreRange(min = JRE.JAVA_17) // RecordingStream
    @Timeout(10)
    public void jfrBufferAllocationThreadLocal() throws Exception {
        ByteBufAllocator alloc = new AdaptiveByteBufAllocator(true, true);

        Callable<Void> allocateAndRelease = () -> {
            try (RecordingStream stream = new RecordingStream()) {
                CompletableFuture<RecordedEvent> allocateFuture = new CompletableFuture<>();
                CompletableFuture<RecordedEvent> releaseFuture = new CompletableFuture<>();

                // Prime the cache.
                alloc.directBuffer(128).release();

                stream.enable(AllocateBufferEvent.class);
                stream.onEvent(AllocateBufferEvent.NAME, allocateFuture::complete);
                stream.enable(FreeBufferEvent.class);
                stream.onEvent(FreeBufferEvent.NAME, releaseFuture::complete);
                stream.startAsync();

                // Allocate out of the cache.
                alloc.directBuffer(128).release();

                RecordedEvent allocate = allocateFuture.get();
                assertEquals(128, allocate.getInt("size"));
                assertEquals(128, allocate.getInt("maxFastCapacity"));
                assertEquals(Integer.MAX_VALUE, allocate.getInt("maxCapacity"));
                assertTrue(allocate.getBoolean("chunkPooled"));
                assertTrue(allocate.getBoolean("chunkThreadLocal"));
                assertTrue(allocate.getBoolean("direct"));

                RecordedEvent release = releaseFuture.get();
                assertEquals(128, release.getInt("size"));
                assertEquals(128, release.getInt("maxFastCapacity"));
                assertEquals(Integer.MAX_VALUE, release.getInt("maxCapacity"));
                assertTrue(release.getBoolean("direct"));
                return null;
            }
        };
        FutureTask<Void> task = new FutureTask<>(allocateAndRelease);
        FastThreadLocalThread thread = new FastThreadLocalThread(task);
        thread.start();
        task.get();
    }

Domain

Subdomains

Frequently Asked Questions

What does jfrBufferAllocationThreadLocal() do?
jfrBufferAllocationThreadLocal() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java.
Where is jfrBufferAllocationThreadLocal() defined?
jfrBufferAllocationThreadLocal() is defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java at line 349.
What does jfrBufferAllocationThreadLocal() call?
jfrBufferAllocationThreadLocal() calls 1 function(s): AdaptiveByteBufAllocator.

Analyze Your Own Codebase

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

Try Supermodel Free