Home / Class/ ManualIoEventLoop Class — netty Architecture

ManualIoEventLoop Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad["ManualIoEventLoop"]
  5b394ac8_3e72_9e94_7d05_d43c1bc35e4d["ManualIoEventLoop.java"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|defined in| 5b394ac8_3e72_9e94_7d05_d43c1bc35e4d
  7e2b1134_222c_eb36_b419_c3e9fb7b0ff6["canBlock()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 7e2b1134_222c_eb36_b419_c3e9fb7b0ff6
  ff53f5d6_acc6_2acd_d4c3_cb82cebe3e96["ManualIoEventLoop()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| ff53f5d6_acc6_2acd_d4c3_cb82cebe3e96
  3243c9ef_97fb_dc29_bf4d_d27224070603["Ticker()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 3243c9ef_97fb_dc29_bf4d_d27224070603
  be6ea593_639f_917a_13de_afe35af4ff4a["runNonBlockingTasks()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| be6ea593_639f_917a_13de_afe35af4ff4a
  71302cf5_5128_e497_27ae_5d79625b4107["runAllTasks()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 71302cf5_5128_e497_27ae_5d79625b4107
  5047d6fd_705b_2516_f43b_43d0d4eed8f0["run()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 5047d6fd_705b_2516_f43b_43d0d4eed8f0
  e422e9d3_1ca3_619c_c230_1924aa80fc46["runAllTasksBeforeDestroy()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| e422e9d3_1ca3_619c_c230_1924aa80fc46
  f1d6723d_11e8_2181_bfa8_0f815f8e8b73["runNow()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| f1d6723d_11e8_2181_bfa8_0f815f8e8b73
  3e7e4a66_8309_6caf_79d2_0f675f55fea1["checkCurrentThread()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 3e7e4a66_8309_6caf_79d2_0f675f55fea1
  5c67a711_94d8_0c2e_2269_2064aba35491["wakeup()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 5c67a711_94d8_0c2e_2269_2064aba35491
  43aaa83f_59e6_bcde_d388_a33a77c6dd86["IoEventLoopGroup()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 43aaa83f_59e6_bcde_d388_a33a77c6dd86
  31be7011_04c5_d67d_a56f_00f07816bb6f["ChannelFuture()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 31be7011_04c5_d67d_a56f_00f07816bb6f
  1ea01bfe_aff7_1fed_ded7_0caadc201a25["register()"]
  6e8a7bbd_d782_0f59_8bd2_22f815f8ecad -->|method| 1ea01bfe_aff7_1fed_ded7_0caadc201a25

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/ManualIoEventLoop.java lines 50–681

public class ManualIoEventLoop extends AbstractScheduledEventExecutor implements IoEventLoop {
    private static final Runnable WAKEUP_TASK = () -> {
        // NOOP
    };
    private static final int ST_STARTED = 0;
    private static final int ST_SHUTTING_DOWN = 1;
    private static final int ST_SHUTDOWN = 2;
    private static final int ST_TERMINATED = 3;

    private final AtomicInteger state;
    private final Promise<?> terminationFuture = new DefaultPromise<Void>(GlobalEventExecutor.INSTANCE);
    private final Queue<Runnable> taskQueue = PlatformDependent.newMpscQueue();
    private final IoHandlerContext nonBlockingContext = new IoHandlerContext() {
        @Override
        public boolean canBlock() {
            assert inEventLoop();
            return false;
        }

        @Override
        public long delayNanos(long currentTimeNanos) {
            assert inEventLoop();
            return 0;
        }

        @Override
        public long deadlineNanos() {
            assert inEventLoop();
            return -1;
        }
    };
    private final BlockingIoHandlerContext blockingContext = new BlockingIoHandlerContext();
    private final IoEventLoopGroup parent;
    private final AtomicReference<Thread> owningThread;
    private final IoHandler handler;
    private final Ticker ticker;

    private volatile long gracefulShutdownQuietPeriod;
    private volatile long gracefulShutdownTimeout;
    private long gracefulShutdownStartTime;
    private long lastExecutionTime;
    private boolean initialized;

    /**
     * This allows to specify additional blocking conditions which will be used by the {@link IoHandler} to decide
     * whether it is allowed to block or not.
     */
    protected boolean canBlock() {
        return true;
    }

    /**
     * Create a new {@link IoEventLoop} that is owned by the user and so needs to be driven by the user with the given
     * {@link Thread}. This means that the user is responsible to call either {@link #runNow()} or
     * {@link #run(long)} to execute IO or tasks that were submitted to this {@link IoEventLoop}.
     *
     * @param owningThread      the {@link Thread} that executes the IO and tasks for this {@link IoEventLoop}. The
     *                          user will use this {@link Thread} to call {@link #runNow()} or {@link #run(long)} to
     *                          make progress.
     * @param factory           the {@link IoHandlerFactory} that will be used to create the {@link IoHandler} that is
     *                          used by this {@link IoEventLoop}.
     */
    public ManualIoEventLoop(Thread owningThread, IoHandlerFactory factory) {
        this(null, owningThread, factory);
    }

    /**
     * Create a new {@link IoEventLoop} that is owned by the user and so needs to be driven by the user with the given
     * {@link Thread}. This means that the user is responsible to call either {@link #runNow()} or
     * {@link #run(long)} to execute IO or tasks that were submitted to this {@link IoEventLoop}.
     *
     * @param parent            the parent {@link IoEventLoopGroup} or {@code null} if no parent.
     * @param owningThread      the {@link Thread} that executes the IO and tasks for this {@link IoEventLoop}. The
     *                          user will use this {@link Thread} to call {@link #runNow()} or {@link #run(long)} to
     *                          make progress. If {@code null}, must be set later using
     *                          {@link #setOwningThread(Thread)}.
     * @param factory           the {@link IoHandlerFactory} that will be used to create the {@link IoHandler} that is
     *                          used by this {@link IoEventLoop}.
     */
    public ManualIoEventLoop(IoEventLoopGroup parent, Thread owningThread, IoHandlerFactory factory) {
        this(parent, owningThread, factory, Ticker.systemTicker());

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free