mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-19 06:32:03 +01:00
Dont hardcode thread count
This commit is contained in:
parent
165b7bced2
commit
7ac0834123
@ -78,13 +78,15 @@ public final class MinecraftServer {
|
|||||||
public static final String THREAD_NAME_TICK = "Ms-Tick";
|
public static final String THREAD_NAME_TICK = "Ms-Tick";
|
||||||
|
|
||||||
public static final String THREAD_NAME_BLOCK_BATCH = "Ms-BlockBatchPool";
|
public static final String THREAD_NAME_BLOCK_BATCH = "Ms-BlockBatchPool";
|
||||||
public static final int THREAD_COUNT_BLOCK_BATCH = 4;
|
public static final int THREAD_COUNT_BLOCK_BATCH = getThreadCount("minestom.block-thread-count",
|
||||||
|
Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
|
||||||
public static final String THREAD_NAME_SCHEDULER = "Ms-SchedulerPool";
|
public static final String THREAD_NAME_SCHEDULER = "Ms-SchedulerPool";
|
||||||
public static final int THREAD_COUNT_SCHEDULER = 1;
|
public static final int THREAD_COUNT_SCHEDULER = getThreadCount("minestom.scheduler-thread-count",
|
||||||
|
Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
|
||||||
public static final String THREAD_NAME_PARALLEL_CHUNK_SAVING = "Ms-ParallelChunkSaving";
|
public static final String THREAD_NAME_PARALLEL_CHUNK_SAVING = "Ms-ParallelChunkSaving";
|
||||||
public static final int THREAD_COUNT_PARALLEL_CHUNK_SAVING = 4;
|
public static final int THREAD_COUNT_PARALLEL_CHUNK_SAVING = getThreadCount("minestom.save-thread-count", 2);
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
// Can be modified at performance cost when increased
|
// Can be modified at performance cost when increased
|
||||||
@ -823,4 +825,8 @@ public final class MinecraftServer {
|
|||||||
"You cannot access the manager before MinecraftServer#init, " +
|
"You cannot access the manager before MinecraftServer#init, " +
|
||||||
"if you are developing an extension be sure to retrieve them at least after Extension#preInitialize");*/
|
"if you are developing an extension be sure to retrieve them at least after Extension#preInitialize");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getThreadCount(@NotNull String property, int count) {
|
||||||
|
return Integer.getInteger(property, Math.min(1, count));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user