mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-15 14:40:51 +00:00
So that works
This commit is contained in:
@@ -401,6 +401,8 @@ public class Mantle {
|
||||
private final AtomicLong oldestTectonicPlate = new AtomicLong(0);
|
||||
@Getter
|
||||
public final Set<Long> toUnload = new HashSet<>();
|
||||
@Getter
|
||||
public final Set<Long> toUnloadAsync = new HashSet<>();
|
||||
private int g = 0;
|
||||
|
||||
/**
|
||||
@@ -447,25 +449,61 @@ public class Mantle {
|
||||
}
|
||||
|
||||
public void unloadTectonicPlate() {
|
||||
try {
|
||||
for (Long id : new ArrayList<>(toUnload)) {
|
||||
hyperLock.withLong(id, () -> {
|
||||
TectonicPlate m = loadedRegions.get(id);
|
||||
if (m != null) {
|
||||
try {
|
||||
m.write(fileForRegion(dataFolder, id));
|
||||
loadedRegions.remove(id);
|
||||
lastUse.remove(id);
|
||||
toUnload.remove(id);
|
||||
Iris.info("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (tectonicLimit.get() > toUnload.size()) {
|
||||
try {
|
||||
for (Long id : new ArrayList<>(toUnload)) {
|
||||
hyperLock.withLong(id, () -> {
|
||||
TectonicPlate m = loadedRegions.get(id);
|
||||
if (m != null) {
|
||||
try {
|
||||
m.write(fileForRegion(dataFolder, id));
|
||||
loadedRegions.remove(id);
|
||||
lastUse.remove(id);
|
||||
toUnload.remove(id);
|
||||
Iris.info("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
int u = toUnload.size();
|
||||
for (Long i : new ArrayList<>(toUnload)) {
|
||||
toUnloadAsync.add(i);
|
||||
toUnload.remove(i);
|
||||
if (u <= toUnloadAsync.size()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
BurstExecutor b = MultiBurst.burst.burst(toUnloadAsync.size());
|
||||
b.setMulticore(true);
|
||||
b.queue(() -> {
|
||||
for (Long id : new ArrayList<>(toUnloadAsync)) {
|
||||
hyperLock.withLong(id, () -> {
|
||||
TectonicPlate m = loadedRegions.get(id);
|
||||
if (m != null) {
|
||||
try {
|
||||
m.write(fileForRegion(dataFolder, id));
|
||||
loadedRegions.remove(id);
|
||||
lastUse.remove(id);
|
||||
toUnloadAsync.remove(id);
|
||||
Iris.info("Async Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
b.complete();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ioTectonicUnload.set(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user