mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-15 07:05:44 +01:00
ce270e1412
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: b2f1908c SPIGOT-5783: Add helpful info to UnknownDependencyException e4f46260 SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot. 529a9a69 SPIGOT-5751: Clarify behaviour of block drop-related API methods CraftBukkit Changes:8ea9b138
Remove outdated build delay.ffc2b251
Revert "#675: Fix redirected CommandNodes sometimes not being properly redirected"cb701f6b
#675: Fix redirected CommandNodes sometimes not being properly redirectedc9d7c16b
SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.fad2494a
#673: Fix Craftworld#isChunkLoaded8637ec00
SPIGOT-5751: Made breakNaturally and getDrops returns the correct item if no argument is given Spigot Changes: a99063f7 Rebuild patches Fixes #3602
59 lines
2.4 KiB
Diff
59 lines
2.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 21 Apr 2020 03:51:53 -0400
|
|
Subject: [PATCH] Allow multiple callbacks to schedule for Callback Executor
|
|
|
|
ChunkMapDistance polls multiple entries for pendingChunkUpdates
|
|
|
|
Each of these have the potential to move a chunk in and out of
|
|
"Loaded" state, which will result in multiple callbacks being
|
|
needed within a single tick of ChunkMapDistance
|
|
|
|
Use an ArrayDeque to store this Queue
|
|
|
|
We make sure to also implement a pattern that is recursion safe too.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
index 2caa53a7e143aae32918ecbefc1bdadcab8d61ed..3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -110,24 +110,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
|
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
|
|
|
|
- private Runnable queued;
|
|
+ // Paper start - replace impl with recursive safe multi entry queue
|
|
+ // it's possible to schedule multiple tasks currently, so it's vital we change this impl
|
|
+ // If we recurse into the executor again, we will append to another queue, ensuring task order consistency
|
|
+ private java.util.ArrayDeque<Runnable> queued = new java.util.ArrayDeque<>();
|
|
|
|
@Override
|
|
public void execute(Runnable runnable) {
|
|
- if (queued != null) {
|
|
- throw new IllegalStateException("Already queued");
|
|
+ if (queued == null) {
|
|
+ queued = new java.util.ArrayDeque<>();
|
|
}
|
|
- queued = runnable;
|
|
+ queued.add(runnable);
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
- Runnable task = queued;
|
|
+ if (queued == null) {
|
|
+ return;
|
|
+ }
|
|
+ java.util.ArrayDeque<Runnable> queue = queued;
|
|
queued = null;
|
|
- if (task != null) {
|
|
+ Runnable task;
|
|
+ while ((task = queue.pollFirst()) != null) {
|
|
task.run();
|
|
}
|
|
}
|
|
+ // Paper end
|
|
};
|
|
// CraftBukkit end
|
|
|