misc fixes

This commit is contained in:
mcrcortex
2025-06-09 20:47:40 +10:00
parent f73413e7c0
commit cb599eea0b
2 changed files with 18 additions and 6 deletions

View File

@@ -46,15 +46,19 @@ public class ServiceThreadPool {
//Set worker affinity if possible
CpuLayout.setThreadAffinity(CpuLayout.CORES[2 + (threadId % (CpuLayout.CORES.length - 2))]);
}
if (threadId != 0) {
ThreadUtils.SetSelfThreadPriorityWin32(ThreadUtils.WIN32_THREAD_PRIORITY_LOWEST);
//ThreadUtils.SetSelfThreadPriorityWin32(ThreadUtils.WIN32_THREAD_MODE_BACKGROUND_BEGIN);
}
this.worker(threadId);
});
worker.setDaemon(false);
worker.setName("Service worker #" + i);
if (i == 0) {//Give the first thread normal priority, this helps if the system is under huge load for voxy to get some work done
worker.setPriority(Thread.NORM_PRIORITY);
} else {
worker.setPriority(priority);
}
worker.start();
worker.setUncaughtExceptionHandler(this::handleUncaughtException);
this.workers[i] = worker;

View File

@@ -86,6 +86,9 @@ public class VoxelIngestService {
}
public void enqueueIngest(WorldEngine engine, WorldChunk chunk) {
if (!this.threads.isAlive()) {
return;
}
if (!engine.isLive()) {
throw new IllegalStateException("Tried inserting chunk into WorldEngine that was not alive");
}
@@ -117,7 +120,12 @@ public class VoxelIngestService {
}
this.ingestQueue.add(new IngestSection(chunk.getPos().x, i, chunk.getPos().z, engine, section, bl, sl));
try {
this.threads.execute();
} catch (Exception e) {
Logger.error("Executing had an error: assume shutting down, aborting",e);
break;
}
}
}