From 848efe60a8b389cb0e468c232ce422d3c63f0caf Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 29 Dec 2025 13:00:04 +1000 Subject: [PATCH] things --- .../voxy/common/world/service/VoxelIngestService.java | 3 ++- .../java/me/cortex/voxy/commonImpl/VoxyInstance.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java index c8759a18..01bf2bd1 100644 --- a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java +++ b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java @@ -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(); diff --git a/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java b/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java index 3da76839..fa5ecbb0 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java +++ b/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java @@ -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 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 }