NioEventLoop 是jdk nio多路處理實現(xiàn)同修復jdk nio的bug
1.NioEventLoop繼承SingleThreadEventLoop 重用單線程處理
2.NioEventLoop是組成 pool EventLoopGroup 基本單元
總之好多邊界判斷跟業(yè)務經(jīng)驗之類的代碼,非常煩碎
重要屬性
public final class NioEventLoop extends SingleThreadEventLoop { //綁定 selector Selector selector; //優(yōu)化過的Set集合 private SelectedSelectionKeySet selectedKeys; //引用全局 SelectorProvider private final SelectorProvider provider; /////////////////////////////////////////// //為true時執(zhí)行selector.wakeup() private final AtomicBoolean wakenUp = new AtomicBoolean(); //io任務占時比率 private volatile int ioRatio = 50; //記錄selectionKey撤銷次數(shù) private int cancelledKeys; //處理selector.selectNow() 標志 private boolean needsToSelectAgain; }