This commit is contained in:
RePixelatedMC
2023-12-07 11:26:14 +01:00
parent 6494cded62
commit db43bc300e

View File

@@ -471,21 +471,18 @@ public class Mantle {
try { try {
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0)); Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0));
if (lastUse != null) { if (lastUse != null) {
synchronized (lastUse) { // Synchronize access to lastUse ( GPT Code ) for (Long i : new ArrayList<>(lastUse.keySet())) {
for (Long i : new ArrayList<>(lastUse.keySet())) { // Use ArrayList to avoid ConcurrentModificationException
double finalAdjustedIdleDuration = adjustedIdleDuration.get(); double finalAdjustedIdleDuration = adjustedIdleDuration.get();
hyperLock.withLong(i, () -> { hyperLock.withLong(i, () -> {
Long lastUseTime = lastUse.get(i); // Move the get inside the lock Long lastUseTime = lastUse.get(i);
if (lastUseTime != null && M.ms() - lastUseTime >= finalAdjustedIdleDuration) { if (lastUseTime != null && M.ms() - lastUseTime >= finalAdjustedIdleDuration) {
toUnload.add(i); toUnload.add(i);
Iris.debug("Tectonic Region added to unload"); Iris.debug("Tectonic Region added to unload");
} }
}); });
} }
}
} }
if (IrisSettings.get().getPerformance().AggressiveTectonicUnload if (IrisSettings.get().getPerformance().AggressiveTectonicUnload
&& loadedRegions.size() > forceAggressiveThreshold.get()) { && loadedRegions.size() > forceAggressiveThreshold.get()) {