Not wakeup the EventLoop for writes as they will not cause a flush anyway
This commit is contained in:
parent
f7f808c7e0
commit
1d8a200849
@ -658,11 +658,16 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if (!addTaskWakesUp) {
|
||||
if (!addTaskWakesUp && wakesUpForTask(task)) {
|
||||
wakeup(inEventLoop);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected boolean wakesUpForTask(Runnable task) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void reject() {
|
||||
throw new RejectedExecutionException("event executor terminated");
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
static final class WriteTask implements Runnable {
|
||||
static final class WriteTask implements SingleThreadEventLoop.NonWakeupRunnable {
|
||||
private ChannelHandlerContext ctx;
|
||||
private Object msg;
|
||||
private ChannelPromise promise;
|
||||
@ -391,7 +391,7 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
|
||||
|
||||
private static final Recycler<WriteTask> RECYCLER = new Recycler<WriteTask>() {
|
||||
@Override
|
||||
protected WriteTask newObject(Handle handle) {
|
||||
protected WriteTask newObject(Handle<WriteTask> handle) {
|
||||
return new WriteTask(handle);
|
||||
}
|
||||
};
|
||||
@ -406,9 +406,9 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
|
||||
return task;
|
||||
}
|
||||
|
||||
private final Recycler.Handle handle;
|
||||
private final Recycler.Handle<WriteTask> handle;
|
||||
|
||||
private WriteTask(Recycler.Handle handle) {
|
||||
private WriteTask(Recycler.Handle<WriteTask> handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
|
@ -50,4 +50,14 @@ public abstract class SingleThreadEventLoop extends SingleThreadEventExecutor im
|
||||
public ChannelHandlerInvoker asInvoker() {
|
||||
return invoker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean wakesUpForTask(Runnable task) {
|
||||
return !(task instanceof NonWakeupRunnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marker interface for {@linkRunnable} that will not trigger an {@link #wakeup(boolean)} in all cases.
|
||||
*/
|
||||
interface NonWakeupRunnable extends Runnable { }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user