Attempted fix for world timeout

This commit is contained in:
mcrcortex
2025-06-02 11:47:12 +10:00
parent 34c5c71d77
commit 9d0cf33a45
3 changed files with 10 additions and 4 deletions

View File

@@ -61,6 +61,10 @@ public class VoxyRenderSystem {
public final ChunkBoundRenderer chunkBoundRenderer;
public VoxyRenderSystem(WorldEngine world, ServiceThreadPool threadPool) {
//Keep the world loaded, NOTE: this is done FIRST, to keep and ensure that even if the rest of loading takes more
// than timeout, we keep the world acquired
world.acquireRef();
//Trigger the shared index buffer loading
SharedIndexBuffer.INSTANCE.id();
Capabilities.init();//Ensure clinit is called
@@ -86,9 +90,6 @@ public class VoxyRenderSystem {
this.renderDistanceTracker.setRenderDistance(VoxyConfig.CONFIG.sectionRenderDistance);
this.chunkBoundRenderer = new ChunkBoundRenderer();
//Keep the world loaded
this.worldIn.acquireRef();
}
public void setRenderDistance(int renderDistance) {

View File

@@ -131,7 +131,7 @@ public abstract class VoxyInstance {
if (this.activeWorlds.containsKey(identifier)) {
throw new IllegalStateException("Existing world with identifier");
}
Logger.info("Creating new world engine");
Logger.info("Creating new world engine: " + identifier.getLongHash());
var world = new WorldEngine(this.createStorage(identifier), this);
world.setSaveCallback(this.savingService::enqueueSave);
this.activeWorlds.put(identifier, world);
@@ -158,6 +158,7 @@ public abstract class VoxyInstance {
var world = this.activeWorlds.remove(id);
if (world == null) continue;//Race condition between unlock read and acquire write
if (!world.isWorldIdle()) {this.activeWorlds.put(id, world); continue;}//No longer idle
Logger.info("Shutting down idle world: " + id.getLongHash());
//If is here close and free the world
world.free();
}

View File

@@ -101,4 +101,8 @@ public class WorldIdentifier {
seed = (seed ^ seed >>> 27) * -7723592293110705685L;
return seed ^ seed >>> 31;
}
public long getLongHash() {
return this.hashCode;
}
}