NioEventLoop ensures that all submitted tasks are executed immediately.
Motivation: If a task was submitted when wakenUp value was true, the task didn't get a chance to call Selector#wakeup. So we need to check task queue again before executing select operation. If we don't, the task might be pended until select operation was timed out. It might be pended until idle timeout if IdleStateHandler existed in pipeline. Modifications: Execute Selector#select in a non-blocking manner if there's a task submitted when wakenUp value was true. Result: Every tasks in NioEventLoop will not be pended.
This commit is contained in:
parent
013abb5c58
commit
ee9d8c9162
@ -653,6 +653,16 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a task was submitted when wakenUp value was true, the task didn't get a chance to call
|
||||||
|
// Selector#wakeup. So we need to check task queue again before executing select operation.
|
||||||
|
// If we don't, the task might be pended until select operation was timed out.
|
||||||
|
// It might be pended until idle timeout if IdleStateHandler existed in pipeline.
|
||||||
|
if (hasTasks() && wakenUp.compareAndSet(false, true)) {
|
||||||
|
selector.selectNow();
|
||||||
|
selectCnt = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int selectedKeys = selector.select(timeoutMillis);
|
int selectedKeys = selector.select(timeoutMillis);
|
||||||
selectCnt ++;
|
selectCnt ++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user