Home / Function/ ThreadCache() — netty Function Reference

ThreadCache() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  a51cd1bd_b897_12ec_2936_0326c256d42f["ThreadCache()"]
  f8855572_2abf_1bf6_a32b_5cf6d1cf4947["PooledByteBufAllocatorTest"]
  a51cd1bd_b897_12ec_2936_0326c256d42f -->|defined in| f8855572_2abf_1bf6_a32b_5cf6d1cf4947
  cedeec8b_9344_3cef_05a1_e0c94d65820e["run()"]
  a51cd1bd_b897_12ec_2936_0326c256d42f -->|calls| cedeec8b_9344_3cef_05a1_e0c94d65820e
  style a51cd1bd_b897_12ec_2936_0326c256d42f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java lines 507–551

    private static ThreadCache createNewThreadCache(final PooledByteBufAllocator allocator, final boolean direct)
            throws InterruptedException {
        final CountDownLatch latch = new CountDownLatch(1);
        final CountDownLatch cacheLatch = new CountDownLatch(1);
        final Thread t = new FastThreadLocalThread(new Runnable() {

            @Override
            public void run() {
                final ByteBuf buf;

                if (direct) {
                    buf = allocator.newDirectBuffer(1024, 1024);
                } else {
                    buf = allocator.newHeapBuffer(1024, 1024);
                }

                // Countdown the latch after we allocated a buffer. At this point the cache must exists.
                cacheLatch.countDown();

                buf.writeZero(buf.capacity());

                try {
                    latch.await();
                } catch (InterruptedException e) {
                    throw new IllegalStateException(e);
                }

                buf.release();

                FastThreadLocal.removeAll();
            }
        });
        t.start();

        // Wait until we allocated a buffer and so be sure the thread was started and the cache exists.
        cacheLatch.await();

        return new ThreadCache() {
            @Override
            public void destroy() throws InterruptedException {
                latch.countDown();
                t.join();
            }
        };
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does ThreadCache() do?
ThreadCache() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java.
Where is ThreadCache() defined?
ThreadCache() is defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java at line 507.
What does ThreadCache() call?
ThreadCache() calls 1 function(s): run.

Analyze Your Own Codebase

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

Try Supermodel Free