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:
Trustin Lee 2012-05-25 14:06:33 -07:00
parent 3d490810b8
commit 2395bcd805

View File

@ -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();