mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 11:24:11 +01:00
Fixes a deadlock issue in CraftScheduler
This commit is contained in:
parent
40f7986a11
commit
9715e77852
1 changed files with 5 additions and 1 deletions
|
@ -20,6 +20,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
private final CraftThreadManager craftThreadManager = new CraftThreadManager();
|
private final CraftThreadManager craftThreadManager = new CraftThreadManager();
|
||||||
|
|
||||||
private final LinkedList<Runnable> mainThreadQueue = new LinkedList<Runnable>();
|
private final LinkedList<Runnable> mainThreadQueue = new LinkedList<Runnable>();
|
||||||
|
private final LinkedList<Runnable> syncedTasks = new LinkedList<Runnable>();
|
||||||
|
|
||||||
private final TreeMap<CraftTask,Boolean> schedulerQueue = new TreeMap<CraftTask,Boolean>();
|
private final TreeMap<CraftTask,Boolean> schedulerQueue = new TreeMap<CraftTask,Boolean>();
|
||||||
|
|
||||||
|
@ -111,11 +112,14 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
try {
|
try {
|
||||||
this.currentTick = currentTick;
|
this.currentTick = currentTick;
|
||||||
while (!mainThreadQueue.isEmpty()) {
|
while (!mainThreadQueue.isEmpty()) {
|
||||||
mainThreadQueue.removeFirst().run();
|
syncedTasks.addLast(mainThreadQueue.removeFirst());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
mainThreadLock.unlock();
|
mainThreadLock.unlock();
|
||||||
}
|
}
|
||||||
|
while(!syncedTasks.isEmpty()) {
|
||||||
|
syncedTasks.removeFirst().run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue