add task before starting thread in SingleThreadEventExecutor.execute (#7841)

Motivation:

Minor performance optimisation that prevents thread from blocking due to task not having been added to queue. Discussed #7815.

Modification:

add task to the queue before starting the thread.

Result:

No additional tests.
This commit is contained in:
Dave Moten 2018-04-05 15:57:21 +10:00 committed by Norman Maurer
parent 0a61f055f5
commit 0f4001d598

View File

@ -762,11 +762,9 @@ public abstract class SingleThreadEventExecutor extends AbstractScheduledEventEx
} }
boolean inEventLoop = inEventLoop(); boolean inEventLoop = inEventLoop();
if (inEventLoop) {
addTask(task); addTask(task);
} else { if (!inEventLoop) {
startThread(); startThread();
addTask(task);
if (isShutdown() && removeTask(task)) { if (isShutdown() && removeTask(task)) {
reject(); reject();
} }