Home / Class/ SingleThreadEventLoopTest Class — netty Architecture

SingleThreadEventLoopTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0["SingleThreadEventLoopTest"]
  220c0306_7851_92da_39e2_f00ceff58693["SingleThreadEventLoopTest.java"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|defined in| 220c0306_7851_92da_39e2_f00ceff58693
  5ca63298_4732_10be_189b_a08bea634d8c["newEventLoop()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 5ca63298_4732_10be_189b_a08bea634d8c
  937c4c5f_b959_2282_6690_5c87a010cfea["stopEventLoop()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 937c4c5f_b959_2282_6690_5c87a010cfea
  b3bfac7b_1224_7047_3c47_acf84c07266b["shutdownBeforeStart()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| b3bfac7b_1224_7047_3c47_acf84c07266b
  357fbc91_cbc8_821d_117a_00679a2dc4a6["shutdownAfterStart()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 357fbc91_cbc8_821d_117a_00679a2dc4a6
  46833dd9_b315_29c3_5ea4_b78bade68a99["assertRejection()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 46833dd9_b315_29c3_5ea4_b78bade68a99
  c8c35e0a_5c76_ad2a_5eed_2d9a5326f639["scheduleTaskA()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| c8c35e0a_5c76_ad2a_5eed_2d9a5326f639
  832b8d70_4843_f285_7b26_0b4187e3e09c["scheduleTaskB()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 832b8d70_4843_f285_7b26_0b4187e3e09c
  d26447fb_b8d5_e79f_0159_ee32ad6bf6d2["scheduleTaskC()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| d26447fb_b8d5_e79f_0159_ee32ad6bf6d2
  98ebe171_9998_c2e3_89d5_096f989dee01["testScheduleTask()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 98ebe171_9998_c2e3_89d5_096f989dee01
  cb4cdc2e_011b_438a_b460_d629715f5734["scheduleTaskAtFixedRateA()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| cb4cdc2e_011b_438a_b460_d629715f5734
  9fbfe781_74c5_0b85_e140_f04a27acd80c["scheduleTaskAtFixedRateB()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 9fbfe781_74c5_0b85_e140_f04a27acd80c
  ba499c81_3a16_c6c4_23e5_d0f6f0b8972f["testScheduleTaskAtFixedRate()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| ba499c81_3a16_c6c4_23e5_d0f6f0b8972f
  754ae531_9319_618c_34c8_f2557f647124["scheduleLaggyTaskAtFixedRateA()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0 -->|method| 754ae531_9319_618c_34c8_f2557f647124

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java lines 50–611

public class SingleThreadEventLoopTest {

    private static final Runnable NOOP = new Runnable() {
        @Override
        public void run() { }
    };

    private SingleThreadEventLoopA loopA;
    private SingleThreadEventLoopB loopB;
    private SingleThreadEventLoopC loopC;

    @BeforeEach
    public void newEventLoop() {
        loopA = new SingleThreadEventLoopA();
        loopB = new SingleThreadEventLoopB();
        loopC = new SingleThreadEventLoopC();
    }

    @AfterEach
    public void stopEventLoop() {
        if (!loopA.isShuttingDown()) {
            loopA.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
        }
        if (!loopB.isShuttingDown()) {
            loopB.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
        }
        if (!loopC.isShuttingDown()) {
            loopC.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
        }

        while (!loopA.isTerminated()) {
            try {
                loopA.awaitTermination(1, TimeUnit.DAYS);
            } catch (InterruptedException e) {
                // Ignore
            }
        }
        assertEquals(1, loopA.cleanedUp.get());

        while (!loopB.isTerminated()) {
            try {
                loopB.awaitTermination(1, TimeUnit.DAYS);
            } catch (InterruptedException e) {
                // Ignore
            }
        }

        while (!loopC.isTerminated()) {
            try {
                loopC.awaitTermination(1, TimeUnit.DAYS);
            } catch (InterruptedException e) {
                // Ignore
            }
        }
    }

    @Test
    @SuppressWarnings("deprecation")
    public void shutdownBeforeStart() throws Exception {
        loopA.shutdown();
        assertRejection(loopA);
    }

    @Test
    @SuppressWarnings("deprecation")
    public void shutdownAfterStart() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        loopA.execute(new Runnable() {
            @Override
            public void run() {
                latch.countDown();
            }
        });

        // Wait for the event loop thread to start.
        latch.await();

        // Request the event loop thread to stop.
        loopA.shutdown();
        assertRejection(loopA);

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free