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