Home / Function/ register() — netty Function Reference

register() — netty Function Reference

Architecture documentation for the register() function in NioEventLoop.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  11a1944a_feaf_3e61_83a4_e456bb347439["register()"]
  b837b976_90bd_d303_000d_805c26e1d843["NioEventLoop"]
  11a1944a_feaf_3e61_83a4_e456bb347439 -->|defined in| b837b976_90bd_d303_000d_805c26e1d843
  4733bb3b_c917_0869_d029_8f8cfcc03b71["register0()"]
  11a1944a_feaf_3e61_83a4_e456bb347439 -->|calls| 4733bb3b_c917_0869_d029_8f8cfcc03b71
  style 11a1944a_feaf_3e61_83a4_e456bb347439 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/nio/NioEventLoop.java lines 76–110

    public void register(final SelectableChannel ch, final int interestOps, final NioTask<?> task) {
        ObjectUtil.checkNotNull(ch, "ch");
        if (interestOps == 0) {
            throw new IllegalArgumentException("interestOps must be non-zero.");
        }
        if ((interestOps & ~ch.validOps()) != 0) {
            throw new IllegalArgumentException(
                    "invalid interestOps: " + interestOps + "(validOps: " + ch.validOps() + ')');
        }
        ObjectUtil.checkNotNull(task, "task");

        if (isShutdown()) {
            throw new IllegalStateException("event loop shut down");
        }

        @SuppressWarnings("unchecked")
        final NioTask<SelectableChannel> nioTask = (NioTask<SelectableChannel>) task;
        if (inEventLoop()) {
            register0(ch, interestOps, nioTask);
        } else {
            try {
                // Offload to the EventLoop as otherwise java.nio.channels.spi.AbstractSelectableChannel.register
                // may block for a long time while trying to obtain an internal lock that may be hold while selecting.
                submit(new Runnable() {
                    @Override
                    public void run() {
                        register0(ch, interestOps, nioTask);
                    }
                }).sync();
            } catch (InterruptedException ignore) {
                // Even if interrupted we did schedule it so just mark the Thread as interrupted.
                Thread.currentThread().interrupt();
            }
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does register() do?
register() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/nio/NioEventLoop.java.
Where is register() defined?
register() is defined in transport/src/main/java/io/netty/channel/nio/NioEventLoop.java at line 76.
What does register() call?
register() calls 1 function(s): register0.

Analyze Your Own Codebase

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

Try Supermodel Free