Repository navigation
Fix:RunAllTasks should be implemented by passing the number of tasks - #14542
dreamlike-ocean wants to merge 1 commit into
Conversation
…to run, rather than using a timeout
duration of such tasks is not known, some could be long, other shorts; why you want to use the number of tasks? |
I have checked the code of SingleThreadIoEventLoop::run. Do you have any better ideas @Override
protected void run() {
assert inEventLoop();
do {
runIo();
if (isShuttingDown()) {
ioHandler.prepareToDestroy();
}
runAllTasks(maxTasksPerRun);
// We should continue with our loop until we either confirmed a shutdown or we can suspend it.
} while (!confirmShutdown() && !canSuspend());
}protected static final int DEFAULT_MAX_TASKS_PER_RUN = Math.max(1,
SystemPropertyUtil.getInt("io.netty.eventLoop.maxTaskPerRun", 1024 * 4)) |
|
@dreamlike-ocean I think you are correct here. |
| runTasks ++; | ||
|
|
||
| task = pollTask(); | ||
| if (task == null || runTasks >= maxTasksPerRun) { |
There was a problem hiding this comment.
| if (task == null || runTasks >= maxTasksPerRun) { | |
| if (task == null || runTasks == maxTasksPerRun) { |
| * | ||
| * @return {@code true} if at least one task was run. | ||
| */ | ||
| protected boolean runAllTasks(int maxTasksPerRun) { |
There was a problem hiding this comment.
Let's rename it to something like this and call it from SingleThreadIoEventLoop.
| protected boolean runAllTasks(int maxTasksPerRun) { | |
| protected boolean runAllTasksWithLimit(int maxTasksPerRun) { |
|
Or wait... I think we should better fix it by using a timeout like @franz1981 suggested. Will do a PR shortly |
|
Closed in favor of #14557 |
Motivation:
RunAllTasks should be implemented by passing the number of tasks to run, rather than using a timeout
Modification:
Add an override method to handle running all tasks correctly
Result:
#14165