mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-20 14:08:57 +01:00
Do not immediately re-queue repeating tasks, or they may simply keep repeating on this tick, until the 35ms time limit runs out.
By: Afforess <afforess@gmail.com>
This commit is contained in:
parent
fef0c5fea0
commit
e2f2ed1c17
1 changed files with 6 additions and 1 deletions
|
@ -49,6 +49,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
long firstTick = -1;
|
long firstTick = -1;
|
||||||
long currentTick = -1;
|
long currentTick = -1;
|
||||||
CraftTask first = null;
|
CraftTask first = null;
|
||||||
|
TreeMap<CraftTask, Boolean> nextQueue = new TreeMap<CraftTask, Boolean>();
|
||||||
do {
|
do {
|
||||||
synchronized (schedulerQueue) {
|
synchronized (schedulerQueue) {
|
||||||
first = null;
|
first = null;
|
||||||
|
@ -64,7 +65,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
processTask(first);
|
processTask(first);
|
||||||
if (first.getPeriod() >= 0) {
|
if (first.getPeriod() >= 0) {
|
||||||
first.updateExecution();
|
first.updateExecution();
|
||||||
schedulerQueue.put(first, first.isSync());
|
nextQueue.put(first, first.isSync());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stop = true;
|
stop = true;
|
||||||
|
@ -78,6 +79,10 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
}
|
}
|
||||||
} while (!stop);
|
} while (!stop);
|
||||||
|
|
||||||
|
synchronized (schedulerQueue) {
|
||||||
|
schedulerQueue.putAll(nextQueue);
|
||||||
|
}
|
||||||
|
|
||||||
long sleepTime = 0;
|
long sleepTime = 0;
|
||||||
if (first == null) {
|
if (first == null) {
|
||||||
sleepTime = 60000L;
|
sleepTime = 60000L;
|
||||||
|
|
Loading…
Add table
Reference in a new issue