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 {
|
||||
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,7 +584,6 @@ public class Mantle {
|
||||
return r;
|
||||
}
|
||||
|
||||
return ioBurst.completeValue(() -> {
|
||||
TectonicPlate region;
|
||||
File file = fileForRegion(dataFolder, x, z);
|
||||
if (file.exists()) {
|
||||
@@ -619,8 +618,7 @@ public class Mantle {
|
||||
Iris.debug("Created new Tectonic Plate " + C.DARK_GREEN + x + " " + z);
|
||||
use(k);
|
||||
return region;
|
||||
}).get();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private void use(Long key) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user