EpollEventLoop ensures that all submitted tasks are executed immediately.
Motivation: If a task was submitted when wakenUp value was 1, the task didn't get a chance to produce wakeup event. So we need to check task queue again before calling epoll_wait. If we don't, the task might be pended until epoll_wait was timed out. It might be pended until idle timeout if IdleStateHandler existed in pipeline. Modifications: Execute epoll_wait in a non-blocking manner if there's a task submitted when wakenUp value was 1. Result: Every tasks in EpollEventLoop will not be pended.
This commit is contained in:
parent
7bfcb5520b
commit
013abb5c58
@ -202,6 +202,14 @@ final class EpollEventLoop extends SingleThreadEventLoop {
|
||||
break;
|
||||
}
|
||||
|
||||
// If a task was submitted when wakenUp value was 1, the task didn't get a chance to produce wakeup event.
|
||||
// So we need to check task queue again before calling epoll_wait. If we don't, the task might be pended
|
||||
// until epoll_wait was timed out. It might be pended until idle timeout if IdleStateHandler existed
|
||||
// in pipeline.
|
||||
if (hasTasks() && WAKEN_UP_UPDATER.compareAndSet(this, 0, 1)) {
|
||||
return Native.epollWait(epollFd.intValue(), events, 0);
|
||||
}
|
||||
|
||||
int selectedKeys = Native.epollWait(epollFd.intValue(), events, (int) timeoutMillis);
|
||||
selectCnt ++;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user