Home / File/ IoUringFileRegion.java — netty Source File

IoUringFileRegion.java — netty Source File

Architecture documentation for IoUringFileRegion.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2024 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.channel.uring;

import io.netty.channel.DefaultFileRegion;
import io.netty.channel.FileRegion;
import io.netty.channel.unix.FileDescriptor;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;

import java.io.IOException;
import java.nio.channels.WritableByteChannel;

final class IoUringFileRegion implements FileRegion {
    private static final InternalLogger logger = InternalLoggerFactory.getInstance(IoUringFileRegion.class);

    private static final short SPLICE_TO_PIPE = 1;
    private static final short SPLICE_TO_SOCKET = 2;

    final DefaultFileRegion fileRegion;
    private FileDescriptor[] pipe;
    private int transferred;
    private int pipeLen = -1;

    IoUringFileRegion(DefaultFileRegion fileRegion) {
        this.fileRegion = fileRegion;
    }

    void open() throws IOException {
        fileRegion.open();
        if (pipe == null) {
            pipe = FileDescriptor.pipe();
        }
    }

    IoUringIoOps splice(int fd) {
        if (pipeLen == -1) {
            return spliceToPipe();
        }
        return spliceToSocket(fd, pipeLen);
    }

    IoUringIoOps spliceToPipe() {
        int fileRegionFd = Native.getFd(fileRegion);
        int len = (int) (count() - transferred());
        int offset =  (int) (position() + transferred());
        return IoUringIoOps.newSplice(
// ... (131 more lines)

Domain

Subdomains

Frequently Asked Questions

What does IoUringFileRegion.java do?
IoUringFileRegion.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Telemetry subdomain.
Where is IoUringFileRegion.java in the architecture?
IoUringFileRegion.java is located at transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringFileRegion.java (domain: Buffer, subdomain: Telemetry, directory: transport-classes-io_uring/src/main/java/io/netty/channel/uring).

Analyze Your Own Codebase

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

Try Supermodel Free