mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 06:11:06 +00:00
add unload debug tools
This commit is contained in:
@@ -60,6 +60,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class Mantle {
|
public class Mantle {
|
||||||
|
private static final boolean disableClear = System.getProperty("disableClear", "false").equals("true");
|
||||||
private final File dataFolder;
|
private final File dataFolder;
|
||||||
@Getter
|
@Getter
|
||||||
private final int worldHeight;
|
private final int worldHeight;
|
||||||
@@ -427,7 +428,7 @@ public class Mantle {
|
|||||||
if (lastUse != null && IrisEngineSVC.instance != null) {
|
if (lastUse != null && IrisEngineSVC.instance != null) {
|
||||||
if (!lastUse.isEmpty()) {
|
if (!lastUse.isEmpty()) {
|
||||||
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0));
|
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0));
|
||||||
for (Long i : new ArrayList<>(lastUse.keySet())) {
|
for (long i : new ArrayList<>(lastUse.keySet())) {
|
||||||
double finalAdjustedIdleDuration = adjustedIdleDuration.get();
|
double finalAdjustedIdleDuration = adjustedIdleDuration.get();
|
||||||
hyperLock.withLong(i, () -> {
|
hyperLock.withLong(i, () -> {
|
||||||
Long lastUseTime = lastUse.get(i);
|
Long lastUseTime = lastUse.get(i);
|
||||||
@@ -456,9 +457,16 @@ public class Mantle {
|
|||||||
if (IrisEngineSVC.instance != null) {
|
if (IrisEngineSVC.instance != null) {
|
||||||
try {
|
try {
|
||||||
KList<Long> copy = toUnload.copy();
|
KList<Long> copy = toUnload.copy();
|
||||||
|
if (!disableClear) toUnload.clear();
|
||||||
burst = MultiBurst.burst.burst(copy.size());
|
burst = MultiBurst.burst.burst(copy.size());
|
||||||
burst.setMulticore(copy.size() > tectonicLimit);
|
burst.setMulticore(copy.size() > tectonicLimit);
|
||||||
for (long id : copy) {
|
for (int j = 0; j < copy.size(); j++) {
|
||||||
|
Long id = copy.get(j);
|
||||||
|
if (id == null) {
|
||||||
|
Iris.error("Null id in unloadTectonicPlate at index " + j);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
burst.queue(() ->
|
burst.queue(() ->
|
||||||
hyperLock.withLong(id, () -> {
|
hyperLock.withLong(id, () -> {
|
||||||
TectonicPlate m = loadedRegions.get(id);
|
TectonicPlate m = loadedRegions.get(id);
|
||||||
@@ -467,7 +475,7 @@ public class Mantle {
|
|||||||
m.write(fileForRegion(dataFolder, id));
|
m.write(fileForRegion(dataFolder, id));
|
||||||
loadedRegions.remove(id);
|
loadedRegions.remove(id);
|
||||||
lastUse.remove(id);
|
lastUse.remove(id);
|
||||||
toUnload.remove(id);
|
if (disableClear) toUnload.remove(id);
|
||||||
i.incrementAndGet();
|
i.incrementAndGet();
|
||||||
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
|
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
|
||||||
IrisEngineSVC.instance.unloadActiveAlive.reset();
|
IrisEngineSVC.instance.unloadActiveAlive.reset();
|
||||||
@@ -476,7 +484,6 @@ public class Mantle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
burst.complete();
|
burst.complete();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user