AbstractKQueueUnsafe Class — netty Architecture
Architecture documentation for the AbstractKQueueUnsafe class in AbstractKQueueChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD db95214c_090e_b762_6cfd_37721de6cf7b["AbstractKQueueUnsafe"] 4fc08dac_39ea_00be_b5ca_bc44decb1b8f["AbstractKQueueChannel.java"] db95214c_090e_b762_6cfd_37721de6cf7b -->|defined in| 4fc08dac_39ea_00be_b5ca_bc44decb1b8f 67779a46_8c0d_0195_c8c0_def1e5211ca4["Channel()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| 67779a46_8c0d_0195_c8c0_def1e5211ca4 2d707c46_2640_96dd_81ba_e8d5602be577["ident()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| 2d707c46_2640_96dd_81ba_e8d5602be577 6cfc6ba6_4961_3030_0b05_046c480b76d2["close()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| 6cfc6ba6_4961_3030_0b05_046c480b76d2 9771c7d3_2655_1640_a268_5f99c6abe7f6["handle()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| 9771c7d3_2655_1640_a268_5f99c6abe7f6 a72f411b_4868_de0d_77b8_4bc581d51883["readReady()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| a72f411b_4868_de0d_77b8_4bc581d51883 e583e7ca_d04e_87b8_fffb_47048fc27d3c["shouldStopReading()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| e583e7ca_d04e_87b8_fffb_47048fc27d3c d2ea9046_f7dc_694b_b7a7_9bc6720f94be["failConnectPromise()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| d2ea9046_f7dc_694b_b7a7_9bc6720f94be bb35de56_68d0_f65e_249e_407bce9a4a7b["writeReady()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| bb35de56_68d0_f65e_249e_407bce9a4a7b def1f904_d411_f912_d2ef_f5e394e5558d["shutdownInput()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| def1f904_d411_f912_d2ef_f5e394e5558d 2f67cad3_9f57_8aaa_bf51_d7df80344b13["readEOF()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| 2f67cad3_9f57_8aaa_bf51_d7df80344b13 e1c66bc8_37c4_58ed_28a2_675c8226995c["KQueueRecvByteAllocatorHandle()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| e1c66bc8_37c4_58ed_28a2_675c8226995c 29eab5c2_d461_b826_de12_095b5485b40f["flush0()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| 29eab5c2_d461_b826_de12_095b5485b40f e425e90c_5fae_6366_33cb_5a4c102b5399["clearReadFilter0()"] db95214c_090e_b762_6cfd_37721de6cf7b -->|method| e425e90c_5fae_6366_33cb_5a4c102b5399
Relationship Graph
Source Code
transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java lines 372–690
@UnstableApi
public abstract class AbstractKQueueUnsafe extends AbstractUnsafe implements KQueueIoHandle {
boolean readPending;
private KQueueRecvByteAllocatorHandle allocHandle;
Channel channel() {
return AbstractKQueueChannel.this;
}
@Override
public int ident() {
return fd().intValue();
}
@Override
public void close() {
close(voidPromise());
}
@Override
public void handle(IoRegistration registration, IoEvent event) {
KQueueIoEvent kqueueEvent = (KQueueIoEvent) event;
final short filter = kqueueEvent.filter();
final short flags = kqueueEvent.flags();
final int fflags = kqueueEvent.fflags();
final long data = kqueueEvent.data();
// First check for EPOLLOUT as we may need to fail the connect ChannelPromise before try
// to read from the file descriptor.
if (filter == Native.EVFILT_WRITE) {
writeReady();
} else if (filter == Native.EVFILT_READ) {
// Check READ before EOF to ensure all data is read before shutting down the input.
KQueueRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();
readReady(allocHandle);
} else if (filter == Native.EVFILT_SOCK && (fflags & Native.NOTE_RDHUP) != 0) {
readEOF();
return;
}
// Check if EV_EOF was set, this will notify us for connection-reset in which case
// we may close the channel directly or try to read more data depending on the state of the
// Channel and also depending on the AbstractKQueueChannel subtype.
if ((flags & Native.EV_EOF) != 0) {
readEOF();
}
}
abstract void readReady(KQueueRecvByteAllocatorHandle allocHandle);
final boolean shouldStopReading(ChannelConfig config) {
// Check if there is a readPending which was not processed yet.
// This could be for two reasons:
// * The user called Channel.read() or ChannelHandlerContext.read() in channelRead(...) method
// * The user called Channel.read() or ChannelHandlerContext.read() in channelReadComplete(...) method
//
// See https://github.com/netty/netty/issues/2254
return !readPending && !config.isAutoRead();
}
final boolean failConnectPromise(Throwable cause) {
if (connectPromise != null) {
// SO_ERROR has been shown to return 0 on macOS if detect an error via read() and the write filter was
// not set before calling connect. This means finishConnect will not detect any error and would
// successfully complete the connectPromise and update the channel state to active (which is incorrect).
ChannelPromise connectPromise = AbstractKQueueChannel.this.connectPromise;
AbstractKQueueChannel.this.connectPromise = null;
if (connectPromise.tryFailure((cause instanceof ConnectException) ? cause
: new ConnectException("failed to connect").initCause(cause))) {
closeIfClosed();
return true;
}
}
return false;
}
private void writeReady() {
if (connectPromise != null) {
// pending connect which is now complete so handle it.
finishConnect();
} else if (!socket.isOutputShutdown()) {
Defined In
Source
Frequently Asked Questions
What is the AbstractKQueueUnsafe class?
AbstractKQueueUnsafe is a class in the netty codebase, defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java.
Where is AbstractKQueueUnsafe defined?
AbstractKQueueUnsafe is defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java at line 372.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free