Fix crash on macos
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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))]);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user