IoUringStreamUnsafe Class — netty Architecture
Architecture documentation for the IoUringStreamUnsafe class in AbstractIoUringStreamChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2ef046a1_16aa_1708_4ba7_113c9fa2862e["IoUringStreamUnsafe"] 73a81342_a975_761a_6c8b_73ab452505f8["AbstractIoUringStreamChannel.java"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|defined in| 73a81342_a975_761a_6c8b_73ab452505f8 f79cc71e_f1c6_3e9c_e16e_f88b23e7f8ba["scheduleWriteMultiple()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| f79cc71e_f1c6_3e9c_e16e_f88b23e7f8ba aa27f60f_99c6_9ce3_938c_4faef8f8c2f4["filterWriteMultiple()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| aa27f60f_99c6_9ce3_938c_4faef8f8c2f4 5d8defc6_646e_bae7_319e_865c37d1c5ed["scheduleWriteSingle()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 5d8defc6_646e_bae7_319e_865c37d1c5ed f3971f93_dbcb_2767_5244_f09d3a29db3d["calculateRecvFlags()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| f3971f93_dbcb_2767_5244_f09d3a29db3d 7684e1d1_c90a_3647_fca5_52c1485dbb4e["calculateRecvIoPrio()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 7684e1d1_c90a_3647_fca5_52c1485dbb4e 59498236_2b4d_5c66_9f07_08c2b7375a6b["scheduleRead0()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 59498236_2b4d_5c66_9f07_08c2b7375a6b fa8d19bc_1143_f4c3_84c4_ef07823cb9be["scheduleReadProviderBuffer()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| fa8d19bc_1143_f4c3_84c4_ef07823cb9be fa9874cc_cb17_d11f_1021_bfddfcbc3051["readComplete0()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| fa9874cc_cb17_d11f_1021_bfddfcbc3051 37bc920a_61ff_3bfd_7186_4dfa81d6398d["scheduleNextRead()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 37bc920a_61ff_3bfd_7186_4dfa81d6398d 21fb1737_9ce6_a472_6c2b_0339632901d1["handleReadException()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 21fb1737_9ce6_a472_6c2b_0339632901d1 97d8bd30_3581_f2a7_44ef_aa6255a7a64e["handleWriteCompleteFileRegion()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 97d8bd30_3581_f2a7_44ef_aa6255a7a64e 883343ab_9c59_4e9f_32b3_d1e64fd67a0e["writeComplete0()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 883343ab_9c59_4e9f_32b3_d1e64fd67a0e 8f895470_9ed1_05de_32c8_feb93065e1c7["unregistered()"] 2ef046a1_16aa_1708_4ba7_113c9fa2862e -->|method| 8f895470_9ed1_05de_32c8_feb93065e1c7
Relationship Graph
Source Code
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringStreamChannel.java lines 234–623
protected class IoUringStreamUnsafe extends AbstractUringUnsafe {
private ByteBuf readBuffer;
@Override
protected int scheduleWriteMultiple(ChannelOutboundBuffer in) {
assert writeId == 0;
int fd = fd().intValue();
IoRegistration registration = registration();
IoUringIoHandler handler = registration.attachment();
IovArray iovArray = handler.iovArray();
int offset = iovArray.count();
try {
in.forEachFlushedMessage(filterWriteMultiple(iovArray));
} catch (Exception e) {
// This should never happen, anyway fallback to single write.
return scheduleWriteSingle(in.current());
}
long iovArrayAddress = iovArray.memoryAddress(offset);
int iovArrayLength = iovArray.count() - offset;
// Should not use sendmsg_zc, just use normal writev.
IoUringIoOps ops = IoUringIoOps.newWritev(fd, (byte) 0, 0, iovArrayAddress, iovArrayLength, nextOpsId());
byte opCode = ops.opcode();
writeId = registration.submit(ops);
writeOpCode = opCode;
if (writeId == 0) {
return 0;
}
return 1;
}
protected ChannelOutboundBuffer.MessageProcessor filterWriteMultiple(IovArray iovArray) {
return iovArray;
}
@Override
protected int scheduleWriteSingle(Object msg) {
assert writeId == 0;
int fd = fd().intValue();
IoRegistration registration = registration();
final IoUringIoOps ops;
if (msg instanceof IoUringFileRegion) {
IoUringFileRegion fileRegion = (IoUringFileRegion) msg;
try {
fileRegion.open();
} catch (IOException e) {
this.handleWriteError(e);
return 0;
}
ops = fileRegion.splice(fd);
} else {
ByteBuf buf = (ByteBuf) msg;
long address = IoUring.memoryAddress(buf) + buf.readerIndex();
int length = buf.readableBytes();
short opsid = nextOpsId();
ops = IoUringIoOps.newSend(fd, (byte) 0, 0, address, length, opsid);
}
byte opCode = ops.opcode();
writeId = registration.submit(ops);
writeOpCode = opCode;
if (writeId == 0) {
return 0;
}
return 1;
}
private int calculateRecvFlags(boolean first) {
// Depending on if this is the first read or not we will use Native.MSG_DONTWAIT.
// The idea is that if the socket is blocking we can do the first read in a blocking fashion
// and so not need to also register POLLIN. As we can not 100 % sure if reads after the first will
// be possible directly we schedule these with Native.MSG_DONTWAIT. This allows us to still be
// able to signal the fireChannelReadComplete() in a timely manner and be consistent with other
// transports.
if (first) {
return 0;
}
Defined In
Source
Frequently Asked Questions
What is the IoUringStreamUnsafe class?
IoUringStreamUnsafe is a class in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringStreamChannel.java.
Where is IoUringStreamUnsafe defined?
IoUringStreamUnsafe is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringStreamChannel.java at line 234.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free