Home / Class/ SpliceFdTask Class — netty Architecture

SpliceFdTask Class — netty Architecture

Architecture documentation for the SpliceFdTask class in AbstractEpollStreamChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  6f5c6f08_1102_30ab_f45d_612a94bd5756["SpliceFdTask"]
  70734405_31fd_71db_63bc_2114f3b39591["AbstractEpollStreamChannel.java"]
  6f5c6f08_1102_30ab_f45d_612a94bd5756 -->|defined in| 70734405_31fd_71db_63bc_2114f3b39591
  267e372f_847e_9019_79b4_ebdfb605fa60["SpliceFdTask()"]
  6f5c6f08_1102_30ab_f45d_612a94bd5756 -->|method| 267e372f_847e_9019_79b4_ebdfb605fa60
  2d4cd98e_9464_bc0c_02b4_94166b830478["spliceIn()"]
  6f5c6f08_1102_30ab_f45d_612a94bd5756 -->|method| 2d4cd98e_9464_bc0c_02b4_94166b830478

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java lines 999–1053

    private final class SpliceFdTask extends SpliceInTask {
        private final FileDescriptor fd;
        private final ChannelPromise promise;
        private int offset;

        SpliceFdTask(FileDescriptor fd, int offset, int len, ChannelPromise promise) {
            super(len, promise);
            this.fd = fd;
            this.promise = promise;
            this.offset = offset;
        }

        @Override
        public boolean spliceIn(RecvByteBufAllocator.Handle handle) {
            assert eventLoop().inEventLoop();
            if (len == 0) {
                // Use trySuccess() as the promise might already be failed by spliceTo(...)
                promise.trySuccess();
                return true;
            }

            try {
                FileDescriptor[] pipe = pipe();
                FileDescriptor pipeIn = pipe[0];
                FileDescriptor pipeOut = pipe[1];
                try {
                    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;
                        }
                        do {
                            int splicedOut = Native.splice(pipeIn.intValue(), -1, fd.intValue(), offset, splicedIn);
                            offset += splicedOut;
                            splicedIn -= splicedOut;
                        } while (splicedIn > 0);
                        if (len == 0) {
                            // Use trySuccess() as the promise might already be failed by spliceTo(...)
                            promise.trySuccess();
                            return true;
                        }
                    }
                    return false;
                } finally {
                    safeClosePipe(pipeIn);
                    safeClosePipe(pipeOut);
                }
            } catch (Throwable cause) {
                // Use tryFailure(...) as the promise might already be failed by spliceTo(...)
                promise.tryFailure(cause);
                return true;
            }
        }
    }

Frequently Asked Questions

What is the SpliceFdTask class?
SpliceFdTask is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java.
Where is SpliceFdTask defined?
SpliceFdTask is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java at line 999.

Analyze Your Own Codebase

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

Try Supermodel Free