Home / Class/ TestableIoEventLoop Class — netty Architecture

TestableIoEventLoop Class — netty Architecture

Architecture documentation for the TestableIoEventLoop class in MultiThreadIoEventLoopGroupTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  58be7942_44d1_cd6e_f39f_cad5938b2ce3["TestableIoEventLoop"]
  e0d4d133_322e_1155_8441_23fad36b03b0["MultiThreadIoEventLoopGroupTest.java"]
  58be7942_44d1_cd6e_f39f_cad5938b2ce3 -->|defined in| e0d4d133_322e_1155_8441_23fad36b03b0
  b0487777_4003_5f28_0e33_0c9427053cf5["TestableIoEventLoop()"]
  58be7942_44d1_cd6e_f39f_cad5938b2ce3 -->|method| b0487777_4003_5f28_0e33_0c9427053cf5
  d2742b96_6092_a292_9533_c669707fc8db["setSimulateWorkload()"]
  58be7942_44d1_cd6e_f39f_cad5938b2ce3 -->|method| d2742b96_6092_a292_9533_c669707fc8db
  9830fcb8_e5b5_cc90_d277_35c9a3443446["run()"]
  58be7942_44d1_cd6e_f39f_cad5938b2ce3 -->|method| 9830fcb8_e5b5_cc90_d277_35c9a3443446
  e7216bcb_a2a0_53a6_a153_909bbbfe6b3c["newTaskQueue()"]
  58be7942_44d1_cd6e_f39f_cad5938b2ce3 -->|method| e7216bcb_a2a0_53a6_a153_909bbbfe6b3c

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/MultiThreadIoEventLoopGroupTest.java lines 90–127

    private static class TestableIoEventLoop extends SingleThreadIoEventLoop {
        private final AtomicBoolean simulateWorkload = new AtomicBoolean(false);

        TestableIoEventLoop(IoEventLoopGroup parent, Executor executor, IoHandlerFactory ioHandlerFactory) {
            super(parent, executor, ioHandlerFactory);
        }

        public void setSimulateWorkload(boolean active) {
            simulateWorkload.set(active);
            if (active) {
                execute(() -> { /* NO-OP */ });
            }
        }

        @Override
        protected void run() {
            do {
                if (simulateWorkload.get()) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                    }
                    reportActiveIoTime(TimeUnit.MILLISECONDS.toNanos(100));
                } else {
                    Runnable task = takeTask();
                    if (task != null) {
                        safeExecute(task);
                    }
                }
            } while (!confirmShutdown() && !canSuspend());
        }

        @Override
        protected Queue<Runnable> newTaskQueue(int maxPendingTasks) {
            return new LinkedBlockingQueue<>(maxPendingTasks);
        }
    }

Frequently Asked Questions

What is the TestableIoEventLoop class?
TestableIoEventLoop is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/MultiThreadIoEventLoopGroupTest.java.
Where is TestableIoEventLoop defined?
TestableIoEventLoop is defined in transport/src/test/java/io/netty/channel/MultiThreadIoEventLoopGroupTest.java at line 90.

Analyze Your Own Codebase

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

Try Supermodel Free