Repository: netty/netty
File: transport-native-epoll/src/test/java/io/netty/channel/epoll/ManualEventLoopTest.java (Java)

Code before:
                    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();
    }

    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();
        CountDownLatch completed = new CountDownLatch(1);
        // depending on canBlockAttempt this submission could observe an AWAKE event loop

Review comment (suggestion):
```suggestion
    private void racyOtherSubmissionMissWakeup(IoHandlerFactory handlerFactory, long canBlockAttempt)
```

Code after:
                    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();
        CountDownLatch completed = new CountDownLatch(1);
        // depending on canBlockAttempt this submission could observe an AWAKE event loop