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:
@@ -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,43 +584,41 @@ 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()) {
|
try {
|
||||||
try {
|
Iris.addPanic("reading.tectonic-plate", file.getAbsolutePath());
|
||||||
Iris.addPanic("reading.tectonic-plate", file.getAbsolutePath());
|
region = worker.read(file.getName());
|
||||||
region = worker.read(file.getName());
|
|
||||||
|
|
||||||
if (region.getX() != x || region.getZ() != 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);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use(k);
|
loadedRegions.put(k, region);
|
||||||
return 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);
|
use(k);
|
||||||
return region;
|
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) {
|
private void use(Long key) {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user