9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-19 15:09:18 +00:00

revert mantle change to hopefully fix deadlock

This commit is contained in:
Julian Krings
2025-09-04 13:54:28 +02:00
parent e51b632c8f
commit 9e147774bd
2 changed files with 38 additions and 35 deletions

View File

@@ -531,7 +531,7 @@ public class Mantle {
try { try {
if (!trim || !unload) { if (!trim || !unload) {
try { try {
return getSafe(x, z); return getSafe(x, z).get();
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -546,7 +546,7 @@ public class Mantle {
} }
try { try {
return getSafe(x, z); return getSafe(x, z).get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Iris.warn("Failed to get Tectonic Plate " + x + " " + z + " Due to a thread intterruption (hotload?)"); Iris.warn("Failed to get Tectonic Plate " + x + " " + z + " Due to a thread intterruption (hotload?)");
Iris.reportError(e); Iris.reportError(e);
@@ -575,8 +575,8 @@ public class Mantle {
* @return the future of a tectonic plate. * @return the future of a tectonic plate.
*/ */
@RegionCoordinates @RegionCoordinates
private TectonicPlate getSafe(int x, int z) throws Throwable { private Future<TectonicPlate> getSafe(int x, int z) {
return hyperLock.withNastyResult(x, z, () -> { return ioBurst.completeValue(() -> hyperLock.withResult(x, z, () -> {
Long k = key(x, z); Long k = key(x, z);
use(k); use(k);
TectonicPlate r = loadedRegions.get(k); TectonicPlate r = loadedRegions.get(k);
@@ -584,7 +584,6 @@ public class Mantle {
return r; return r;
} }
return ioBurst.completeValue(() -> {
TectonicPlate region; TectonicPlate region;
File file = fileForRegion(dataFolder, x, z); File file = fileForRegion(dataFolder, x, z);
if (file.exists()) { if (file.exists()) {
@@ -619,8 +618,7 @@ public class Mantle {
Iris.debug("Created new Tectonic Plate " + C.DARK_GREEN + x + " " + z); Iris.debug("Created new Tectonic Plate " + C.DARK_GREEN + x + " " + z);
use(k); use(k);
return region; return region;
}).get(); }));
});
} }
private void use(Long key) { private void use(Long key) {

View File

@@ -29,6 +29,11 @@ public class StreamUtils {
@SneakyThrows @SneakyThrows
public static <T> void forEach(Stream<T> stream, Consumer<T> task, @Nullable MultiBurst burst) { public static <T> void forEach(Stream<T> stream, Consumer<T> task, @Nullable MultiBurst burst) {
if (burst == null) stream.forEach(task); if (burst == null) stream.forEach(task);
else burst.submit(() -> stream.parallel().forEach(task)).get(); else {
var list = stream.toList();
var exec = burst.burst(list.size());
list.forEach(val -> exec.queue(() -> task.accept(val)));
exec.complete();
}
} }
} }