mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-06 15:31:43 +01:00
Fast exit if task queue is empty
This commit is contained in:
parent
5c6d0dc7b2
commit
9af41f944a
@ -53,13 +53,15 @@ final class SchedulerImpl implements Scheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run all tasks lock-free, either in the current thread or pool
|
// Run all tasks lock-free, either in the current thread or pool
|
||||||
this.taskQueue.drain(task -> {
|
if (!taskQueue.isEmpty()) {
|
||||||
if (!task.isAlive()) return;
|
this.taskQueue.drain(task -> {
|
||||||
switch (task.executionType()) {
|
if (!task.isAlive()) return;
|
||||||
case SYNC -> handleTask(task);
|
switch (task.executionType()) {
|
||||||
case ASYNC -> EXECUTOR.submit(() -> handleTask(task));
|
case SYNC -> handleTask(task);
|
||||||
}
|
case ASYNC -> EXECUTOR.submit(() -> handleTask(task));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user