-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make loadChunksAsync callback thread-safe
Need to perform synchronisation on the return list to avoid CMEs
- Loading branch information
1 parent
57983f7
commit b2d7bdb
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
patches/server/0024-Make-loadChunksAsync-callback-thread-safe.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Spottedleaf <[email protected]> | ||
Date: Tue, 25 Jul 2023 11:47:18 -0700 | ||
Subject: [PATCH] Make loadChunksAsync callback thread-safe | ||
|
||
Need to perform synchronisation on the return list to avoid CMEs | ||
|
||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java | ||
index 60b409e873d8f5d7975cce6e86ee2ed5525d348c..cf8f93734121e5c1959959f0ba13ee4e6db31959 100644 | ||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java | ||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java | ||
@@ -347,7 +347,9 @@ public class ServerLevel extends Level implements WorldGenLevel { | ||
|
||
java.util.function.Consumer<net.minecraft.world.level.chunk.ChunkAccess> consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> { | ||
if (chunk != null) { | ||
+ synchronized (ret) { // Folia - region threading - make callback thread-safe TODO rebase | ||
ret.add(chunk); | ||
+ } // Folia - region threading - make callback thread-safe TODO rebase | ||
chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel, holderIdentifier); | ||
} | ||
if (loadedChunks.incrementAndGet() == requiredChunks) { |