Home / Function/ register0() — netty Function Reference

register0() — netty Function Reference

Architecture documentation for the register0() function in AbstractChannel.java from the netty codebase.

Function java Buffer Search calls 7 called by 1

Entity Profile

Dependency Diagram

graph TD
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7["register0()"]
  330d05c9_85ca_2e57_92f5_e996fb442b81["AbstractUnsafe"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|defined in| 330d05c9_85ca_2e57_92f5_e996fb442b81
  7ac63885_60f4_64a0_2bb5_20c6a0c6de73["register()"]
  7ac63885_60f4_64a0_2bb5_20c6a0c6de73 -->|calls| 3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7
  202ee03c_4c4c_7ecd_fbf8_3c6f0228198d["ensureOpen()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| 202ee03c_4c4c_7ecd_fbf8_3c6f0228198d
  bc29f802_b297_1770_91f3_caeb36e61763["safeSetSuccess()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| bc29f802_b297_1770_91f3_caeb36e61763
  64ffc4ac_efb7_a405_54dc_2d1b3d7fab48["beginRead()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| 64ffc4ac_efb7_a405_54dc_2d1b3d7fab48
  3247fe36_e8dd_2a94_aca8_58f72f5210e8["close()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| 3247fe36_e8dd_2a94_aca8_58f72f5210e8
  4b71a6cb_9d50_676e_bce9_aabd595de051["setClosed()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| 4b71a6cb_9d50_676e_bce9_aabd595de051
  09594916_b369_0dde_fab6_d2f3c2bd81b1["safeSetFailure()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| 09594916_b369_0dde_fab6_d2f3c2bd81b1
  fa166003_ef8f_51b4_955f_a802a471c179["doRegister()"]
  3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 -->|calls| fa166003_ef8f_51b4_955f_a802a471c179
  style 3636c0b5_4718_d99f_6eb8_ab7c7fc1bcc7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/AbstractChannel.java lines 366–406

        private void register0(ChannelPromise promise) {
            // check if the channel is still open as it could be closed in the mean time when the register
            // call was outside of the eventLoop
            if (!promise.setUncancellable() || !ensureOpen(promise)) {
                return;
            }
            ChannelPromise registerPromise = newPromise();
            boolean firstRegistration = neverRegistered;
            registerPromise.addListener(future -> {
                if (future.isSuccess()) {
                    neverRegistered = false;
                    registered = true;

                    // Ensure we call handlerAdded(...) before we actually notify the promise. This is needed as the
                    // user may already fire events through the pipeline in the ChannelFutureListener.
                    pipeline.invokeHandlerAddedIfNeeded();

                    safeSetSuccess(promise);
                    pipeline.fireChannelRegistered();
                    // Only fire a channelActive if the channel has never been registered. This prevents firing
                    // multiple channel actives if the channel is deregistered and re-registered.
                    if (isActive()) {
                        if (firstRegistration) {
                            pipeline.fireChannelActive();
                        } else if (config().isAutoRead()) {
                            // This channel was registered before and autoRead() is set. This means we need to
                            // begin read again so that we process inbound data.
                            //
                            // See https://github.com/netty/netty/issues/4805
                            beginRead();
                        }
                    }
                } else {
                    // Close the channel directly to avoid FD leak.
                    close(newPromise());
                    closeFuture.setClosed();
                    safeSetFailure(promise, future.cause());
                }
            });
            doRegister(registerPromise);
        }

Domain

Subdomains

Called By

Frequently Asked Questions

What does register0() do?
register0() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/AbstractChannel.java.
Where is register0() defined?
register0() is defined in transport/src/main/java/io/netty/channel/AbstractChannel.java at line 366.
What does register0() call?
register0() calls 7 function(s): beginRead, close, doRegister, ensureOpen, safeSetFailure, safeSetSuccess, setClosed.
What calls register0()?
register0() is called by 1 function(s): register.

Analyze Your Own Codebase

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

Try Supermodel Free