IoUringSocketChannel Class — netty Architecture
Architecture documentation for the IoUringSocketChannel class in IoUringSocketChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 25906582_4e71_62ea_f4db_27f5b9345598["IoUringSocketChannel"] 14cc29cd_5951_1ece_1055_ff870dd87de5["IoUringSocketChannel.java"] 25906582_4e71_62ea_f4db_27f5b9345598 -->|defined in| 14cc29cd_5951_1ece_1055_ff870dd87de5 5c11cab2_8972_6686_4eea_7076323010ad["IoUringSocketChannel()"] 25906582_4e71_62ea_f4db_27f5b9345598 -->|method| 5c11cab2_8972_6686_4eea_7076323010ad 3e8b2921_7e54_d582_b418_a23c9fea090e["ServerSocketChannel()"] 25906582_4e71_62ea_f4db_27f5b9345598 -->|method| 3e8b2921_7e54_d582_b418_a23c9fea090e 0378f510_77c5_7a7f_b634_ee2a3e3f8653["SocketChannelConfig()"] 25906582_4e71_62ea_f4db_27f5b9345598 -->|method| 0378f510_77c5_7a7f_b634_ee2a3e3f8653 16517960_344a_2819_66eb_1f54885a88b2["InetSocketAddress()"] 25906582_4e71_62ea_f4db_27f5b9345598 -->|method| 16517960_344a_2819_66eb_1f54885a88b2 1f40fa2b_adcb_0ec4_7a32_62732cd0b43a["AbstractUringUnsafe()"] 25906582_4e71_62ea_f4db_27f5b9345598 -->|method| 1f40fa2b_adcb_0ec4_7a32_62732cd0b43a
Relationship Graph
Source Code
transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringSocketChannel.java lines 33–311
public final class IoUringSocketChannel extends AbstractIoUringStreamChannel implements SocketChannel {
private final IoUringSocketChannelConfig config;
public IoUringSocketChannel() {
super(null, LinuxSocket.newSocketStream(), false);
this.config = new IoUringSocketChannelConfig(this);
}
IoUringSocketChannel(Channel parent, LinuxSocket fd) {
super(parent, fd, true);
this.config = new IoUringSocketChannelConfig(this);
}
IoUringSocketChannel(Channel parent, LinuxSocket fd, SocketAddress remote) {
super(parent, fd, remote);
this.config = new IoUringSocketChannelConfig(this);
}
@Override
public ServerSocketChannel parent() {
return (ServerSocketChannel) super.parent();
}
@Override
public SocketChannelConfig config() {
return config;
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
protected AbstractUringUnsafe newUnsafe() {
return new IoUringSocketUnsafe();
}
// Marker object that is used to mark a batch of buffers that were used with zero-copy write operations.
private static final Object ZC_BATCH_MARKER = new Object();
private final class IoUringSocketUnsafe extends IoUringStreamUnsafe {
/**
* Queue that holds buffers that we can't release yet as the kernel still holds a reference to these.
*/
private Queue<Object> zcWriteQueue;
@Override
protected int scheduleWriteSingle(Object msg) {
assert writeId == 0;
if (IoUring.isSendZcSupported() && msg instanceof ByteBuf) {
ByteBuf buf = (ByteBuf) msg;
int length = buf.readableBytes();
if (((IoUringSocketChannelConfig) config()).shouldWriteZeroCopy(length)) {
long address = IoUring.memoryAddress(buf) + buf.readerIndex();
IoUringIoOps ops = IoUringIoOps.newSendZc(fd().intValue(), address, length, 0, nextOpsId(), 0);
byte opCode = ops.opcode();
writeId = registration().submit(ops);
writeOpCode = opCode;
if (writeId == 0) {
return 0;
}
return 1;
}
// Should not use send_zc, just use normal write.
}
return super.scheduleWriteSingle(msg);
}
@Override
protected int scheduleWriteMultiple(ChannelOutboundBuffer in) {
assert writeId == 0;
IoUringSocketChannelConfig ioUringSocketChannelConfig = (IoUringSocketChannelConfig) config();
//at least one buffer in the batch exceeds `IO_URING_WRITE_ZERO_COPY_THRESHOLD`.
Defined In
Source
Frequently Asked Questions
What is the IoUringSocketChannel class?
IoUringSocketChannel is a class in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringSocketChannel.java.
Where is IoUringSocketChannel defined?
IoUringSocketChannel is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringSocketChannel.java at line 33.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free