Fast exit if task queue is empty

This commit is contained in:
themode 2021-12-16 16:07:07 +01:00 committed by TheMode
parent 5c6d0dc7b2
commit 9af41f944a

View File

@ -53,6 +53,7 @@ final class SchedulerImpl implements Scheduler {
}
}
// Run all tasks lock-free, either in the current thread or pool
if (!taskQueue.isEmpty()) {
this.taskQueue.drain(task -> {
if (!task.isAlive()) return;
switch (task.executionType()) {
@ -61,6 +62,7 @@ final class SchedulerImpl implements Scheduler {
}
});
}
}
@Override
public @NotNull Task submitTask(@NotNull Supplier<TaskSchedule> task,