mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 02:19:19 +00:00
Faster sequencing of futures for chunk structure gen
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 2 Jan 2024 21:13:53 -0500
|
||||
Subject: [PATCH] Faster sequencing of futures for chunk structure gen
|
||||
|
||||
Replace `thenApply` with `thenCompose`. Once one task is completed then the next task starts immediately,
|
||||
to prevent blocking threads while waiting to complete all tasks
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||
index 22dfe70df68b35e313f94b17a87e4121392b17b4..8fc746ec89eb8052e723227eac890407d9b34938 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -412,9 +412,11 @@ public class Util {
|
||||
return futures.get(0).thenApply(List::of);
|
||||
} else {
|
||||
CompletableFuture<Void> completableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
- return completableFuture.thenApply((void_) -> {
|
||||
- return futures.stream().map(CompletableFuture::join).toList();
|
||||
- });
|
||||
+ // Leaf start - Faster sequencing of futures for chunk structure gen
|
||||
+ return completableFuture.thenCompose((void_) ->
|
||||
+ CompletableFuture.supplyAsync(() ->
|
||||
+ futures.stream().map(CompletableFuture::join).toList()));
|
||||
+ // Leaf end
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user