Home / Class/ EmbeddedEventLoop Class — netty Architecture

EmbeddedEventLoop Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  f5c313f0_9cdb_f508_5009_ccd6eb752c36["EmbeddedEventLoop"]
  4e307a37_725f_c65e_2729_80961dc4b390["EmbeddedEventLoop.java"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|defined in| 4e307a37_725f_c65e_2729_80961dc4b390
  a5c7a324_fd4e_3fd8_03fe_e0befeac21ac["EmbeddedEventLoop()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| a5c7a324_fd4e_3fd8_03fe_e0befeac21ac
  3cb7c9d7_ab2f_cb67_9fff_f06c1a4f285c["EventLoopGroup()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 3cb7c9d7_ab2f_cb67_9fff_f06c1a4f285c
  810ddd26_54a1_11cf_860d_0cb1d087abfb["EventLoop()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 810ddd26_54a1_11cf_860d_0cb1d087abfb
  809e38bc_f107_f9f9_6145_f98eee869744["execute()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 809e38bc_f107_f9f9_6145_f98eee869744
  08c70ffc_b270_5bd4_2a7e_a7c6ef06fff1["runTasks()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 08c70ffc_b270_5bd4_2a7e_a7c6ef06fff1
  003ab3c5_c2c8_4cb3_a28c_06d91eab9fd0["hasPendingNormalTasks()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 003ab3c5_c2c8_4cb3_a28c_06d91eab9fd0
  a65964fb_9648_2a95_bf58_6943fd29131a["runScheduledTasks()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| a65964fb_9648_2a95_bf58_6943fd29131a
  2fb8d5a6_bc03_fcb0_8d21_70de359de4ed["nextScheduledTask()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 2fb8d5a6_bc03_fcb0_8d21_70de359de4ed
  cbcd06f3_cc8b_a18c_352c_f83531f08e2e["Ticker()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| cbcd06f3_cc8b_a18c_352c_f83531f08e2e
  f6e0e30f_0e29_ceca_bfbe_08c3564790a3["getCurrentTimeNanos()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| f6e0e30f_0e29_ceca_bfbe_08c3564790a3
  3a05793a_3c0c_27a0_041f_026721200ef3["cancelScheduledTasks()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 3a05793a_3c0c_27a0_041f_026721200ef3
  6a0ad7f0_2681_0c0b_87cb_0f514c109f67["shutdownGracefully()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| 6a0ad7f0_2681_0c0b_87cb_0f514c109f67
  b3b8aef7_c0b2_8f30_ba38_787404c80ec8["terminationFuture()"]
  f5c313f0_9cdb_f508_5009_ccd6eb752c36 -->|method| b3b8aef7_c0b2_8f30_ba38_787404c80ec8

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java lines 34–231

final class EmbeddedEventLoop extends AbstractScheduledEventExecutor implements EventLoop {
    private final Ticker ticker;

    private final Queue<Runnable> tasks = new ArrayDeque<Runnable>(2);

    EmbeddedEventLoop(Ticker ticker) {
        this.ticker = ticker;
    }

    @Override
    public EventLoopGroup parent() {
        return (EventLoopGroup) super.parent();
    }

    @Override
    public EventLoop next() {
        return (EventLoop) super.next();
    }

    @Override
    public void execute(Runnable command) {
        tasks.add(ObjectUtil.checkNotNull(command, "command"));
    }

    void runTasks() {
        for (;;) {
            Runnable task = tasks.poll();
            if (task == null) {
                break;
            }

            task.run();
        }
    }

    boolean hasPendingNormalTasks() {
        return !tasks.isEmpty();
    }

    long runScheduledTasks() {
        long time = getCurrentTimeNanos();
        for (;;) {
            Runnable task = pollScheduledTask(time);
            if (task == null) {
                return nextScheduledTaskNano();
            }

            task.run();
        }
    }

    long nextScheduledTask() {
        return nextScheduledTaskNano();
    }

    @Override
    public Ticker ticker() {
        return ticker;
    }

    @Override
    protected long getCurrentTimeNanos() {
        return ticker.nanoTime();
    }

    @Override
    protected void cancelScheduledTasks() {
        super.cancelScheduledTasks();
    }

    @Override
    public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Future<?> terminationFuture() {
        throw new UnsupportedOperationException();
    }

    @Override

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free