This commit is contained in:
mcrcortex
2025-12-29 13:00:04 +10:00
parent 470534831b
commit 848efe60a8
2 changed files with 13 additions and 1 deletions

View File

@@ -119,6 +119,7 @@ public class VoxelIngestService {
for (var section : chunk.getSections()) {
i++;
if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue;
engine.markActive();
this.ingestQueue.add(new IngestSection(chunk.getPos().x, i, chunk.getPos().z, engine, section, null, null));
try {
this.service.execute();
@@ -158,7 +159,7 @@ public class VoxelIngestService {
//if (blNone && slNone) {
// continue;
//}
engine.markActive();
this.ingestQueue.add(new IngestSection(chunk.getPos().x, i, chunk.getPos().z, engine, section, bl, sl));//TODO: fixme, this is technically not safe todo on the chunk load ingest, we need to copy the section data so it cant be modified while being read
try {
this.service.execute();

View File

@@ -127,12 +127,18 @@ public abstract class VoxyInstance {
}
public WorldEngine getOrCreate(WorldIdentifier identifier) {
return this.getOrCreate(identifier, false);
}
public WorldEngine getOrCreate(WorldIdentifier identifier, boolean incrementRef) {
if (!this.isRunning) {
Logger.error("Tried getting world object on voxy instance but its not running");
return null;
}
var world = this.getNullable(identifier);
if (world != null) {
world.markActive();
if (incrementRef) world.acquireRef();
return world;
}
long stamp = this.activeWorldLock.writeLock();
@@ -147,6 +153,10 @@ public abstract class VoxyInstance {
//Create world here
world = this.createWorld(identifier);
}
world.markActive();
if (incrementRef) world.acquireRef();
this.activeWorldLock.unlockWrite(stamp);
identifier.cachedEngineObject = new WeakReference<>(world);
return world;
@@ -199,6 +209,7 @@ public abstract class VoxyInstance {
public void addDebug(List<String> debug) {
debug.add("MemoryBuffer, Count/Size (mb): " + MemoryBuffer.getCount() + "/" + (MemoryBuffer.getTotalSize()/1_000_000));
//TODO: fixme, doing this.activeWorlds.values() is not thread safe
debug.add("I/S/AWSC: " + this.ingestService.getTaskCount() + "/" + this.savingService.getTaskCount() + "/[" + this.activeWorlds.values().stream().map(a->""+a.getActiveSectionCount()).collect(Collectors.joining(", ")) + "]");//Active world section count
}