Home / Class/ EmbeddedUnsafe Class — netty Architecture

EmbeddedUnsafe Class — netty Architecture

Architecture documentation for the EmbeddedUnsafe class in EmbeddedChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  e733a376_1730_c587_d317_2c9f4c7f3740["EmbeddedUnsafe"]
  da14aac1_b6b5_44dd_f197_278e22c2b814["EmbeddedChannel.java"]
  e733a376_1730_c587_d317_2c9f4c7f3740 -->|defined in| da14aac1_b6b5_44dd_f197_278e22c2b814
  fd0b7433_d81b_a8cd_838d_946f9413d9b8["connect()"]
  e733a376_1730_c587_d317_2c9f4c7f3740 -->|method| fd0b7433_d81b_a8cd_838d_946f9413d9b8

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java lines 1189–1334

    private final class EmbeddedUnsafe extends AbstractUnsafe {

        // Delegates to the EmbeddedUnsafe instance but ensures runPendingTasks() is called after each operation
        // that may change the state of the Channel and may schedule tasks for later execution.
        final Unsafe wrapped = new Unsafe() {
            @Override
            public RecvByteBufAllocator.Handle recvBufAllocHandle() {
                return EmbeddedUnsafe.this.recvBufAllocHandle();
            }

            @Override
            public SocketAddress localAddress() {
                return EmbeddedUnsafe.this.localAddress();
            }

            @Override
            public SocketAddress remoteAddress() {
                return EmbeddedUnsafe.this.remoteAddress();
            }

            @Override
            public void register(EventLoop eventLoop, ChannelPromise promise) {
                executingStackCnt++;
                try {
                    EmbeddedUnsafe.this.register(eventLoop, promise);
                } finally {
                    executingStackCnt--;
                    maybeRunPendingTasks();
                }
            }

            @Override
            public void bind(SocketAddress localAddress, ChannelPromise promise) {
                executingStackCnt++;
                try {
                    EmbeddedUnsafe.this.bind(localAddress, promise);
                } finally {
                    executingStackCnt--;
                    maybeRunPendingTasks();
                }
            }

            @Override
            public void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
                executingStackCnt++;
                try {
                    EmbeddedUnsafe.this.connect(remoteAddress, localAddress, promise);
                } finally {
                    executingStackCnt--;
                    maybeRunPendingTasks();
                }
            }

            @Override
            public void disconnect(ChannelPromise promise) {
                executingStackCnt++;
                try {
                    EmbeddedUnsafe.this.disconnect(promise);
                } finally {
                    executingStackCnt--;
                    maybeRunPendingTasks();
                }
            }

            @Override
            public void close(ChannelPromise promise) {
                executingStackCnt++;
                try {
                    EmbeddedUnsafe.this.close(promise);
                } finally {
                    executingStackCnt--;
                    maybeRunPendingTasks();
                }
            }

            @Override
            public void closeForcibly() {
                executingStackCnt++;
                try {
                    EmbeddedUnsafe.this.closeForcibly();
                } finally {

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free