Home / File/ FileDescriptor.java — netty Source File

FileDescriptor.java — netty Source File

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

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2015 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.unix;


import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

import static io.netty.channel.unix.Errors.ioResult;
import static io.netty.channel.unix.Errors.newIOException;
import static io.netty.channel.unix.Limits.IOV_MAX;
import static io.netty.util.internal.ObjectUtil.checkNotNull;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import static java.lang.Math.min;

/**
 * Native {@link FileDescriptor} implementation which allows to wrap an {@code int} and provide a
 * {@link FileDescriptor} for it.
 */
public class FileDescriptor {

    private static final AtomicIntegerFieldUpdater<FileDescriptor> stateUpdater =
            AtomicIntegerFieldUpdater.newUpdater(FileDescriptor.class, "state");

    private static final int STATE_CLOSED_MASK = 1;
    private static final int STATE_INPUT_SHUTDOWN_MASK = 1 << 1;
    private static final int STATE_OUTPUT_SHUTDOWN_MASK = 1 << 2;
    private static final int STATE_ALL_MASK = STATE_CLOSED_MASK |
                                              STATE_INPUT_SHUTDOWN_MASK |
                                              STATE_OUTPUT_SHUTDOWN_MASK;

    /**
     * Bit map = [Output Shutdown | Input Shutdown | Closed]
     */
    volatile int state;
    final int fd;

    public FileDescriptor(int fd) {
        checkPositiveOrZero(fd, "fd");
        this.fd = fd;
    }

    /**
     * Return the int value of the filedescriptor.
     */
// ... (181 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free