【发布时间】:2022-01-21 19:09:39
【问题描述】:
Netty 版本 4.1.1.7 最终版。我想知道 if 的用途是什么以及为什么在处理任务之前必须选择#selectNow。
// io.netty.channel.nio.NioEventLoop#select
private void select(boolean oldWakenUp) throws IOException {
// ...
for (;;) {
long timeoutMillis = (selectDeadLineNanos - currentTimeNanos + 500000L) / 1000000L;
if (timeoutMillis <= 0) {
if (selectCnt == 0) {
selector.selectNow();
selectCnt = 1;
}
break;
}
// ...
}
}
【问题讨论】: