FileDescriptor Class — netty Architecture
Architecture documentation for the FileDescriptor class in FileDescriptor.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5c6e37aa_7064_92fb_4b59_7b76ad32e403["FileDescriptor"] bc0bb026_9a85_aef6_d286_0199e0b400ed["FileDescriptor.java"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|defined in| bc0bb026_9a85_aef6_d286_0199e0b400ed 2a6c8488_f313_165b_0bae_cab054b1e82e["FileDescriptor()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 2a6c8488_f313_165b_0bae_cab054b1e82e 4617e26a_a9b0_6d05_c115_a9548f19970b["intValue()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 4617e26a_a9b0_6d05_c115_a9548f19970b 802f1d9f_4e73_6025_da8a_fd85e14dbeea["markClosed()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 802f1d9f_4e73_6025_da8a_fd85e14dbeea bb447b16_4106_b5c3_5492_65b863a59ccc["close()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| bb447b16_4106_b5c3_5492_65b863a59ccc 5e6e555a_16b6_df16_6c12_8bc9aa448e85["isOpen()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 5e6e555a_16b6_df16_6c12_8bc9aa448e85 a47647ca_4033_53e1_3641_96e200527846["write()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| a47647ca_4033_53e1_3641_96e200527846 16412d5a_8fef_4298_5584_d48a3eb9845d["writeAddress()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 16412d5a_8fef_4298_5584_d48a3eb9845d 3c6ee8af_d3e5_52a9_6fdf_ae66b7003d98["writev()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 3c6ee8af_d3e5_52a9_6fdf_ae66b7003d98 091afa8b_4766_8c0e_1cfd_3644b290b54e["writevAddresses()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 091afa8b_4766_8c0e_1cfd_3644b290b54e b52f4a33_dc49_af0e_10b2_e5bafcdea3a4["read()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| b52f4a33_dc49_af0e_10b2_e5bafcdea3a4 970be343_fcf7_5b8c_1d0e_b0d85611f4b7["readAddress()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 970be343_fcf7_5b8c_1d0e_b0d85611f4b7 083f5373_4913_abf1_3e9b_9fc61a99e9b7["String()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| 083f5373_4913_abf1_3e9b_9fc61a99e9b7 c9851097_ddfb_d7f1_a0f2_d5ad09e9a09f["equals()"] 5c6e37aa_7064_92fb_4b59_7b76ad32e403 -->|method| c9851097_ddfb_d7f1_a0f2_d5ad09e9a09f
Relationship Graph
Source Code
transport-native-unix-common/src/main/java/io/netty/channel/unix/FileDescriptor.java lines 35–240
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.
*/
public final int intValue() {
return fd;
}
protected boolean markClosed() {
for (;;) {
int state = this.state;
if (isClosed(state)) {
return false;
}
// Once a close operation happens, the channel is considered shutdown.
if (casState(state, state | STATE_ALL_MASK)) {
return true;
}
}
}
/**
* Close the file descriptor.
*/
public void close() throws IOException {
if (markClosed()) {
int res = close(fd);
if (res < 0) {
throw newIOException("close", res);
}
}
}
/**
* Returns {@code true} if the file descriptor is open.
*/
public boolean isOpen() {
return !isClosed(state);
}
public final int write(ByteBuffer buf, int pos, int limit) throws IOException {
int res = write(fd, buf, pos, limit);
if (res >= 0) {
return res;
}
return ioResult("write", res);
}
public final int writeAddress(long address, int pos, int limit) throws IOException {
int res = writeAddress(fd, address, pos, limit);
if (res >= 0) {
return res;
}
return ioResult("writeAddress", res);
}
public final long writev(ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite) throws IOException {
long res = writev(fd, buffers, offset, min(IOV_MAX, length), maxBytesToWrite);
if (res >= 0) {
Source
Frequently Asked Questions
What is the FileDescriptor class?
FileDescriptor is a class in the netty codebase, defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/FileDescriptor.java.
Where is FileDescriptor defined?
FileDescriptor is defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/FileDescriptor.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free