Home / Class/ AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest Class — netty Architecture

AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest Class — netty Architecture

Architecture documentation for the AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest class in AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  1220e9cf_ffbb_5ac3_1bfe_202607076d2d["AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest"]
  28922f79_99ab_afa7_65e5_acd0b665729d["AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.java"]
  1220e9cf_ffbb_5ac3_1bfe_202607076d2d -->|defined in| 28922f79_99ab_afa7_65e5_acd0b665729d
  559f136a_8dbb_fd63_3c8a_ef401f3ee987["AdaptiveByteBufAllocator()"]
  1220e9cf_ffbb_5ac3_1bfe_202607076d2d -->|method| 559f136a_8dbb_fd63_3c8a_ef401f3ee987
  44b2ed69_4c4b_039c_867e_83e4348e77c1["testFastThreadLocalThreadWithoutCleanupFastThreadLocals()"]
  1220e9cf_ffbb_5ac3_1bfe_202607076d2d -->|method| 44b2ed69_4c4b_039c_867e_83e4348e77c1

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.java lines 26–77

public class AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest extends AdaptiveByteBufAllocatorTest {

    @Override
    protected AdaptiveByteBufAllocator newAllocator(final boolean preferDirect) {
        return new AdaptiveByteBufAllocator(preferDirect, true);
    }

    @Override
    protected AdaptiveByteBufAllocator newUnpooledAllocator() {
        return newAllocator(false);
    }

    @Test
    void testFastThreadLocalThreadWithoutCleanupFastThreadLocals() throws InterruptedException {
        final AtomicReference<Throwable> throwable = new AtomicReference<Throwable>();
        Runnable task = new Runnable() {
            @Override
            public void run() {
                try {
                    AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.super.testUsedHeapMemory();
                    AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.super.testUsedDirectMemory();
                } catch (Throwable e) {
                    throwable.set(e);
                }
            }
        };
        Thread customizefastThreadLocalThread = new CustomizeFastThreadLocalThreadWithoutCleanupFastThreadLocals(task);
        customizefastThreadLocalThread.start();
        customizefastThreadLocalThread.join();
        assertNull(throwable.get());
    }

    private static final class CustomizeFastThreadLocalThreadWithoutCleanupFastThreadLocals
            extends FastThreadLocalThread implements Runnable {

        private final Runnable runnable;

        private CustomizeFastThreadLocalThreadWithoutCleanupFastThreadLocals(Runnable runnable) {
            this.runnable = ObjectUtil.checkNotNull(runnable, "runnable");
        }

        @Override
        public boolean willCleanupFastThreadLocals() {
            return false;
        }

        @Override
        public void run() {
            runnable.run(); // Without calling `FastThreadLocal.removeAll()`.
        }
    }
}

Frequently Asked Questions

What is the AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest class?
AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.java.
Where is AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest defined?
AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest is defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorUseCacheForNonEventLoopThreadsTest.java at line 26.

Analyze Your Own Codebase

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

Try Supermodel Free