Process task queue before start to read
- Otherwise some tasks scheduled right after activation will be executed with 1 second delay.
This commit is contained in:
parent
3d490810b8
commit
2395bcd805
@ -43,17 +43,12 @@ class SingleBlockingChannelEventLoop extends SingleThreadEventLoop {
|
||||
// Waken up by interruptThread()
|
||||
}
|
||||
} else {
|
||||
processTaskQueue();
|
||||
ch.unsafe().read();
|
||||
for (;;) {
|
||||
Runnable task = pollTask();
|
||||
if (task == null) {
|
||||
break;
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
|
||||
// Handle deregistration
|
||||
if (!ch.isRegistered()) {
|
||||
processTaskQueue();
|
||||
deregister();
|
||||
}
|
||||
}
|
||||
@ -64,6 +59,16 @@ class SingleBlockingChannelEventLoop extends SingleThreadEventLoop {
|
||||
}
|
||||
}
|
||||
|
||||
private void processTaskQueue() {
|
||||
for (;;) {
|
||||
Runnable task = pollTask();
|
||||
if (task == null) {
|
||||
break;
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void wakeup(boolean inEventLoop) {
|
||||
interruptThread();
|
||||
|
Loading…
Reference in New Issue
Block a user