Home / Function/ spliceIn() — netty Function Reference

spliceIn() — netty Function Reference

Architecture documentation for the spliceIn() function in AbstractEpollStreamChannel.java from the netty codebase.

Function java Buffer Search calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f["spliceIn()"]
  23ec46b5_b38a_813e_80f1_bf10cbf04b9b["SpliceInChannelTask"]
  bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f -->|defined in| 23ec46b5_b38a_813e_80f1_bf10cbf04b9b
  700d0ecb_1352_b044_4437_4fe399d26b18["spliceIn()"]
  700d0ecb_1352_b044_4437_4fe399d26b18 -->|calls| bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f
  db8fb743_9361_5500_be84_376fbf81160d["write()"]
  bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f -->|calls| db8fb743_9361_5500_be84_376fbf81160d
  b7509f2a_dd40_06f2_0dc7_c50773120f9c["SpliceOutTask()"]
  bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f -->|calls| b7509f2a_dd40_06f2_0dc7_c50773120f9c
  700d0ecb_1352_b044_4437_4fe399d26b18["spliceIn()"]
  bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f -->|calls| 700d0ecb_1352_b044_4437_4fe399d26b18
  style bf05d7ae_8b8c_3fe2_87fc_0d5befffe40f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java lines 905–962

        @Override
        public boolean spliceIn(RecvByteBufAllocator.Handle handle) {
            assert ch.eventLoop().inEventLoop();
            if (len == 0) {
                // Use trySuccess() as the promise might already be closed by spliceTo(...)
                promise.trySuccess();
                return true;
            }
            try {
                // We create the pipe on the target channel as this will allow us to just handle pending writes
                // later in a correct fashion without get into any ordering issues when spliceTo(...) is called
                // on multiple Channels pointing to one target Channel.
                FileDescriptor pipeOut = ch.pipeOut;
                if (pipeOut == null) {
                    // Create a new pipe as non was created before.
                    FileDescriptor[] pipe = pipe();
                    ch.pipeIn = pipe[0];
                    pipeOut = ch.pipeOut = pipe[1];
                }

                int splicedIn = spliceIn(pipeOut, handle);
                if (splicedIn > 0) {
                    // Integer.MAX_VALUE is a special value which will result in splice forever.
                    if (len != Integer.MAX_VALUE) {
                        len -= splicedIn;
                    }

                    // Depending on if we are done with splicing inbound data we set the right promise for the
                    // outbound splicing.
                    final ChannelPromise splicePromise;
                    if (len == 0) {
                        splicePromise = promise;
                    } else {
                        splicePromise = ch.newPromise().addListener(this);
                    }

                    boolean autoRead = config().isAutoRead();

                    // Just call unsafe().write(...) and flush() as we not want to traverse the whole pipeline for this
                    // case.
                    ch.unsafe().write(new SpliceOutTask(ch, splicedIn, autoRead), splicePromise);
                    ch.unsafe().flush();
                    if (autoRead && !splicePromise.isDone()) {
                        // Write was not done which means the target channel was not writable. In this case we need to
                        // disable reading until we are done with splicing to the target channel because:
                        //
                        // - The user may want to trigger another splice operation once the splicing was complete.
                        config().setAutoRead(false);
                    }
                }

                return len == 0;
            } catch (Throwable cause) {
                // Use tryFailure(...) as the promise might already be closed by spliceTo(...)
                promise.tryFailure(cause);
                return true;
            }
        }

Domain

Subdomains

Called By

Frequently Asked Questions

What does spliceIn() do?
spliceIn() is a function in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java.
Where is spliceIn() defined?
spliceIn() is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java at line 905.
What does spliceIn() call?
spliceIn() calls 3 function(s): SpliceOutTask, spliceIn, write.
What calls spliceIn()?
spliceIn() is called by 1 function(s): spliceIn.

Analyze Your Own Codebase

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

Try Supermodel Free