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);
|
wakeup(inEventLoop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
protected boolean wakesUpForTask(Runnable task) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected static void reject() {
|
protected static void reject() {
|
||||||
throw new RejectedExecutionException("event executor terminated");
|
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 ChannelHandlerContext ctx;
|
||||||
private Object msg;
|
private Object msg;
|
||||||
private ChannelPromise promise;
|
private ChannelPromise promise;
|
||||||
@ -391,7 +391,7 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
|
|||||||
|
|
||||||
private static final Recycler<WriteTask> RECYCLER = new Recycler<WriteTask>() {
|
private static final Recycler<WriteTask> RECYCLER = new Recycler<WriteTask>() {
|
||||||
@Override
|
@Override
|
||||||
protected WriteTask newObject(Handle handle) {
|
protected WriteTask newObject(Handle<WriteTask> handle) {
|
||||||
return new WriteTask(handle);
|
return new WriteTask(handle);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -406,9 +406,9 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
|
|||||||
return task;
|
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;
|
this.handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,4 +50,14 @@ public abstract class SingleThreadEventLoop extends SingleThreadEventExecutor im
|
|||||||
public ChannelHandlerInvoker asInvoker() {
|
public ChannelHandlerInvoker asInvoker() {
|
||||||
return invoker;
|
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…
Reference in New Issue
Block a user