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 {
if (!trim || !unload) {
try {
return getSafe(x, z);
return getSafe(x, z).get();
} catch (Throwable e) {
e.printStackTrace();
}
@@ -546,7 +546,7 @@ public class Mantle {
}
try {
return getSafe(x, z);
return getSafe(x, z).get();
} catch (InterruptedException e) {
Iris.warn("Failed to get Tectonic Plate " + x + " " + z + " Due to a thread intterruption (hotload?)");
Iris.reportError(e);
@@ -575,8 +575,8 @@ public class Mantle {
* @return the future of a tectonic plate.
*/
@RegionCoordinates
private TectonicPlate getSafe(int x, int z) throws Throwable {
return hyperLock.withNastyResult(x, z, () -> {
private Future<TectonicPlate> getSafe(int x, int z) {
return ioBurst.completeValue(() -> hyperLock.withResult(x, z, () -> {
Long k = key(x, z);
use(k);
TectonicPlate r = loadedRegions.get(k);
@@ -584,43 +584,41 @@ public class Mantle {
return r;
}
return ioBurst.completeValue(() -> {
TectonicPlate region;
File file = fileForRegion(dataFolder, x, z);
if (file.exists()) {
try {
Iris.addPanic("reading.tectonic-plate", file.getAbsolutePath());
region = worker.read(file.getName());
TectonicPlate region;
File file = fileForRegion(dataFolder, x, z);
if (file.exists()) {
try {
Iris.addPanic("reading.tectonic-plate", file.getAbsolutePath());
region = worker.read(file.getName());
if (region.getX() != x || region.getZ() != z) {
Iris.warn("Loaded Tectonic Plate " + x + "," + z + " but read it as " + region.getX() + "," + region.getZ() + "... Assuming " + x + "," + z);
}
loadedRegions.put(k, region);
Iris.debug("Loaded Tectonic Plate " + C.DARK_GREEN + x + " " + z + C.DARK_AQUA + " " + file.getName());
} catch (Throwable e) {
Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead.");
Iris.reportError(e);
if (!(e instanceof EOFException)) {
e.printStackTrace();
}
Iris.panic();
region = new TectonicPlate(worldHeight, x, z);
loadedRegions.put(k, region);
Iris.debug("Created new Tectonic Plate (Due to Load Failure) " + C.DARK_GREEN + x + " " + z);
if (region.getX() != x || region.getZ() != z) {
Iris.warn("Loaded Tectonic Plate " + x + "," + z + " but read it as " + region.getX() + "," + region.getZ() + "... Assuming " + x + "," + z);
}
use(k);
return region;
loadedRegions.put(k, region);
Iris.debug("Loaded Tectonic Plate " + C.DARK_GREEN + x + " " + z + C.DARK_AQUA + " " + file.getName());
} catch (Throwable e) {
Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead.");
Iris.reportError(e);
if (!(e instanceof EOFException)) {
e.printStackTrace();
}
Iris.panic();
region = new TectonicPlate(worldHeight, x, z);
loadedRegions.put(k, region);
Iris.debug("Created new Tectonic Plate (Due to Load Failure) " + C.DARK_GREEN + x + " " + z);
}
region = new TectonicPlate(worldHeight, x, z);
loadedRegions.put(k, region);
Iris.debug("Created new Tectonic Plate " + C.DARK_GREEN + x + " " + z);
use(k);
return region;
}).get();
});
}
region = new TectonicPlate(worldHeight, x, z);
loadedRegions.put(k, region);
Iris.debug("Created new Tectonic Plate " + C.DARK_GREEN + x + " " + z);
use(k);
return region;
}));
}
private void use(Long key) {

View File

@@ -29,6 +29,11 @@ public class StreamUtils {
@SneakyThrows
public static <T> void forEach(Stream<T> stream, Consumer<T> task, @Nullable MultiBurst burst) {
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();
}
}
}