Home / Class/ ManualEventLoopTest Class — netty Architecture

ManualEventLoopTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685["ManualEventLoopTest"]
  225130a2_5093_d89c_ccad_1b5f3b519fae["ManualEventLoopTest.java"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|defined in| 225130a2_5093_d89c_ccad_1b5f3b519fae
  affd8661_2609_7b31_4428_aa4e1953879e["firstRacySubmissionMissWakeupEpoll()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| affd8661_2609_7b31_4428_aa4e1953879e
  1c2f0eff_f804_4fab_6465_439e9677bcb2["secondRacySubmissionMissWakeupEpoll()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| 1c2f0eff_f804_4fab_6465_439e9677bcb2
  42afbec2_1dfb_e08c_b283_a1e6579cd752["firstRacyOtherSubmissionMissWakeupEpoll()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| 42afbec2_1dfb_e08c_b283_a1e6579cd752
  6d1b089c_a048_4926_376c_556dad8e7de4["secondRacyOtherSubmissionMissWakeupEpoll()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| 6d1b089c_a048_4926_376c_556dad8e7de4
  da7bff55_39c9_598a_d0b5_6573386604bf["racySubmissionMissWakeup()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| da7bff55_39c9_598a_d0b5_6573386604bf
  e2eaad12_7108_a22e_49dd_3bdd336a1360["racyOtherSubmissionMissWakeup()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| e2eaad12_7108_a22e_49dd_3bdd336a1360
  03587724_2d5f_fb39_1c76_c50295ce4670["testTightShutodownEpoll()"]
  e45aee7f_05b1_581f_0dc9_9f5ffbeab685 -->|method| 03587724_2d5f_fb39_1c76_c50295ce4670

Relationship Graph

Source Code

transport-native-epoll/src/test/java/io/netty/channel/epoll/ManualEventLoopTest.java lines 39–224

@Timeout(5)
public class ManualEventLoopTest {

    @Test
    void firstRacySubmissionMissWakeupEpoll() throws Exception {
        racySubmissionMissWakeup(EpollIoHandler.newFactory(), 1);
    }

    @Test
    void secondRacySubmissionMissWakeupEpoll() throws Exception {
        racySubmissionMissWakeup(EpollIoHandler.newFactory(), 2);
    }

    @Test
    void firstRacyOtherSubmissionMissWakeupEpoll() throws Exception {
        racyOtherSubmissionMissWakeup(EpollIoHandler.newFactory(), 1);
    }

    @Test
    void secondRacyOtherSubmissionMissWakeupEpoll() throws Exception {
        racyOtherSubmissionMissWakeup(EpollIoHandler.newFactory(), 2);
    }

    private void racySubmissionMissWakeup(IoHandlerFactory handlerFactory, long canBlockAttempt)
            throws Exception {
        CyclicBarrier waitBeforeSubmittingTask = new CyclicBarrier(2);
        CountDownLatch taskSubmitted = new CountDownLatch(1);
        AtomicLong canBlock = new AtomicLong(0);
        ManualMultithreadedIoEventLoopGroup group = new ManualMultithreadedIoEventLoopGroup(handlerFactory) {
            @Override
            protected void beforeCanBlock(Executor executor) {
                if (canBlock.incrementAndGet() == canBlockAttempt) {
                    try {
                        waitBeforeSubmittingTask.await();
                    } catch (Throwable ignore) {
                        //
                    }
                    try {
                        taskSubmitted.await();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        waitBeforeSubmittingTask.await();
        // depending on canBlockAttempt this submission could observe an AWAKE event loop
        // or with a setup NONE deadline (e.g. Long.MAX_VALUE).
        // In the latter case, it can be already asleep or ready to do it.
        Future<?> submitted = group.submit(() -> {
        });
        // unblock canBlock
        taskSubmitted.countDown();
        submitted.get();
        group.shutdownGracefully(0, 0, TimeUnit.SECONDS).get();
    }

    private void racyOtherSubmissionMissWakeup(IoHandlerFactory handlerFactory, long canBlockAttempt)
            throws Exception {
        CyclicBarrier waitBeforeSubmittingTask = new CyclicBarrier(2);
        CountDownLatch taskSubmitted = new CountDownLatch(1);
        AtomicLong canBlock = new AtomicLong(0);
        ManualMultithreadedIoEventLoopGroup group = new ManualMultithreadedIoEventLoopGroup(handlerFactory) {
            @Override
            protected void beforeCanBlock(Executor executor) {
                // this should be called when canBlock is called after setting the wakeup flag!
                if (canBlock.incrementAndGet() == canBlockAttempt) {
                    try {
                        waitBeforeSubmittingTask.await();
                    } catch (Throwable ignore) {
                        //
                    }
                    try {
                        taskSubmitted.await();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        waitBeforeSubmittingTask.await();

Frequently Asked Questions

What is the ManualEventLoopTest class?
ManualEventLoopTest is a class in the netty codebase, defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/ManualEventLoopTest.java.
Where is ManualEventLoopTest defined?
ManualEventLoopTest is defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/ManualEventLoopTest.java at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free