Ensure chunk gen tasks return to main thread before completing futures

This commit is contained in:
Spottedleaf 2020-06-10 23:24:35 -04:00
parent 3ef000597a
commit 4347fa1b85

View file

@ -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<Either<IChunkAccess, PlayerChunk.Failure>> 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
}
}