SingleThreadIoEventLoop Class — netty Architecture
Architecture documentation for the SingleThreadIoEventLoop class in SingleThreadIoEventLoop.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b5a24862_948e_3d05_bb70_270a6c4842a9["SingleThreadIoEventLoop"] efd31c86_62e1_24b2_a3b4_d9f97657dd24["SingleThreadIoEventLoop.java"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|defined in| efd31c86_62e1_24b2_a3b4_d9f97657dd24 ecc6c655_5b9f_e4d0_8ced_0e2530f50bd8["SingleThreadIoEventLoop()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| ecc6c655_5b9f_e4d0_8ced_0e2530f50bd8 8d5dec0c_2331_5e5c_de10_b2630e1c7837["run()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| 8d5dec0c_2331_5e5c_de10_b2630e1c7837 1521de9d_9b09_12d0_84e4_b6e32bd2ef28["IoHandler()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| 1521de9d_9b09_12d0_84e4_b6e32bd2ef28 b948a0a5_ad0f_b755_a53a_c66ec0c93d69["canSuspend()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| b948a0a5_ad0f_b755_a53a_c66ec0c93d69 b208bf5f_436c_fef2_27fc_abcda4a7d4d6["runIo()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| b208bf5f_436c_fef2_27fc_abcda4a7d4d6 7238ab91_6a71_0b33_6b7e_24f143b2fe8d["IoEventLoop()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| 7238ab91_6a71_0b33_6b7e_24f143b2fe8d 4f1e6e08_477c_0f5f_de68_9d9cb2f051a6["register()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| 4f1e6e08_477c_0f5f_de68_9d9cb2f051a6 d27f60eb_77a7_fd1e_1bf0_4d1be942fe1d["getNumOfRegisteredChannels()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| d27f60eb_77a7_fd1e_1bf0_4d1be942fe1d 6b494a0c_b088_3d36_2290_76b03d4be72b["registerForIo0()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| 6b494a0c_b088_3d36_2290_76b03d4be72b cbe5ad89_a792_9fe2_a0f9_3e2fe253acac["wakeup()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| cbe5ad89_a792_9fe2_a0f9_3e2fe253acac 83a715bd_94b2_5556_726d_ee52d3bdb09e["cleanup()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| 83a715bd_94b2_5556_726d_ee52d3bdb09e e9558946_ef54_b99e_7fc9_7fce1acdc02a["isCompatible()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| e9558946_ef54_b99e_7fc9_7fce1acdc02a ad1b78e9_6662_36a1_fa3f_fe1494dc6168["isIoType()"] b5a24862_948e_3d05_bb70_270a6c4842a9 -->|method| ad1b78e9_6662_36a1_fa3f_fe1494dc6168
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/SingleThreadIoEventLoop.java lines 36–325
public class SingleThreadIoEventLoop extends SingleThreadEventLoop implements IoEventLoop {
// TODO: Is this a sensible default ?
private static final long DEFAULT_MAX_TASK_PROCESSING_QUANTUM_NS = TimeUnit.MILLISECONDS.toNanos(Math.max(100,
SystemPropertyUtil.getInt("io.netty.eventLoop.maxTaskProcessingQuantumMs", 1000)));
private final long maxTaskProcessingQuantumNs;
private final IoHandlerContext context = new IoHandlerContext() {
@Override
public boolean canBlock() {
assert inEventLoop();
return !hasTasks() && !hasScheduledTasks();
}
@Override
public long delayNanos(long currentTimeNanos) {
assert inEventLoop();
return SingleThreadIoEventLoop.this.delayNanos(currentTimeNanos);
}
@Override
public long deadlineNanos() {
assert inEventLoop();
return SingleThreadIoEventLoop.this.deadlineNanos();
}
@Override
public void reportActiveIoTime(long activeNanos) {
SingleThreadIoEventLoop.this.reportActiveIoTime(activeNanos);
}
@Override
public boolean shouldReportActiveIoTime() {
return isSuspensionSupported();
}
};
private final IoHandler ioHandler;
private final AtomicInteger numRegistrations = new AtomicInteger();
/**
* Creates a new instance
*
* @param parent the parent that holds this {@link IoEventLoop}.
* @param threadFactory the {@link ThreadFactory} that is used to create the underlying {@link Thread}.
* @param ioHandlerFactory the {@link IoHandlerFactory} that should be used to obtain {@link IoHandler} to
* handle IO.
*/
public SingleThreadIoEventLoop(IoEventLoopGroup parent, ThreadFactory threadFactory,
IoHandlerFactory ioHandlerFactory) {
super(parent, threadFactory, false,
ObjectUtil.checkNotNull(ioHandlerFactory, "ioHandlerFactory").isChangingThreadSupported());
this.maxTaskProcessingQuantumNs = DEFAULT_MAX_TASK_PROCESSING_QUANTUM_NS;
this.ioHandler = ioHandlerFactory.newHandler(this);
}
/**
* Creates a new instance
*
* @param parent the parent that holds this {@link IoEventLoop}.
* @param executor the {@link Executor} that is used for dispatching the work.
* @param ioHandlerFactory the {@link IoHandlerFactory} that should be used to obtain {@link IoHandler} to
* handle IO.
*/
public SingleThreadIoEventLoop(IoEventLoopGroup parent, Executor executor, IoHandlerFactory ioHandlerFactory) {
super(parent, executor, false,
ObjectUtil.checkNotNull(ioHandlerFactory, "ioHandlerFactory").isChangingThreadSupported());
this.maxTaskProcessingQuantumNs = DEFAULT_MAX_TASK_PROCESSING_QUANTUM_NS;
this.ioHandler = ioHandlerFactory.newHandler(this);
}
/**
* Creates a new instance
*
* @param parent the parent that holds this {@link IoEventLoop}.
* @param threadFactory the {@link ThreadFactory} that is used to create the underlying
* {@link Thread}.
* @param ioHandlerFactory the {@link IoHandlerFactory} that should be used to obtain {@link IoHandler}
* to handle IO.
* @param maxPendingTasks the maximum pending tasks that are allowed before
Source
Frequently Asked Questions
What is the SingleThreadIoEventLoop class?
SingleThreadIoEventLoop is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/SingleThreadIoEventLoop.java.
Where is SingleThreadIoEventLoop defined?
SingleThreadIoEventLoop is defined in transport/src/main/java/io/netty/channel/SingleThreadIoEventLoop.java at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free