Fix crash on macos

This commit is contained in:
mcrcortex
2025-10-05 22:54:39 +10:00
parent 72d1fccacf
commit b2d62ec807
4 changed files with 12 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ public class VoxyConfig implements OptionStorage<VoxyConfig> {
public boolean enableRendering = true;
public boolean ingestEnabled = true;
public int sectionRenderDistance = 16;
public int serviceThreads = (int) Math.max(CpuLayout.CORES.length/1.5, 1);
public int serviceThreads = (int) Math.max(CpuLayout.getCoreCount()/1.5, 1);
public float subDivisionSize = 64;
public boolean renderVanillaFog = false;
public boolean useEnvironmentalFog = false;

View File

@@ -29,7 +29,7 @@ public class ServiceThreadPool {
}
public ServiceThreadPool(int threadCount, int priority) {
if (CpuLayout.CORES.length-2 < threadCount) {
if (CpuLayout.getCoreCount()-2 < threadCount) {
Logger.warn("The thread count over core count -2, performance degradation possible");
}
@@ -38,7 +38,7 @@ public class ServiceThreadPool {
for (int i = 0; i < threadCount; i++) {
int threadId = i;
var worker = new Thread(this.threadGroup, ()->{
if (CpuLayout.CORES.length>3) {
if (CpuLayout.CORES!=null && CpuLayout.CORES.length>3) {
//Set worker affinity if possible
CpuLayout.setThreadAffinity(CpuLayout.CORES[2 + (threadId % (CpuLayout.CORES.length - 2))]);
}

View File

@@ -156,4 +156,12 @@ public class CpuLayout {
Thread.sleep(100);
}
}
public static int getCoreCount() {
if (CORES==null) {
return Runtime.getRuntime().availableProcessors();
} else {
return CORES.length;
}
}
}