From 4347fa1b8512a9b46b9aed6aceb92c56ee5f151f Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Wed, 10 Jun 2020 23:24:35 -0400 Subject: [PATCH] Ensure chunk gen tasks return to main thread before completing futures --- .../Improve-Chunk-Status-Transition-Speed.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Spigot-Server-Patches/Improve-Chunk-Status-Transition-Speed.patch b/Spigot-Server-Patches/Improve-Chunk-Status-Transition-Speed.patch index 868bc191dd..2fa7eecbdf 100644 --- a/Spigot-Server-Patches/Improve-Chunk-Status-Transition-Speed.patch +++ b/Spigot-Server-Patches/Improve-Chunk-Status-Transition-Speed.patch @@ -90,12 +90,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @Nullable +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + IChunkAccess ichunkaccess = (IChunkAccess) optional.get(); + + if (ichunkaccess.getChunkStatus().b(chunkstatus)) { +- CompletableFuture completablefuture1; ++ CompletableFuture> completablefuture1; // Paper + + if (chunkstatus == ChunkStatus.LIGHT) { + completablefuture1 = this.b(playerchunk, chunkstatus); @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { return this.b(playerchunk, chunkstatus); } } - }, this.executor); -+ }, this.mainInvokingExecutor); // Paper - optimize chunk status progression without jumping through thread pool ++ }, this.mainInvokingExecutor).thenComposeAsync(CompletableFuture::completedFuture, this.mainInvokingExecutor); // Paper - optimize chunk status progression without jumping through thread pool - ensure main } }