Fixed: Включена многопоточность Updatable

This commit is contained in:
Reider745
2024-07-22 07:20:40 +03:00
parent 4438da8c02
commit 99cbbc4974
5 changed files with 18 additions and 6 deletions
+3
View File
@@ -91,6 +91,9 @@ stop-on-critical-ticking-error: false
# Если количесвто пакетов привышает это, то игрок кикается с сервера # Если количесвто пакетов привышает это, то игрок кикается с сервера
max-packet-sending: 200 max-packet-sending: 200
# Дополнительные потоки Updatable
threading_additional_thread_count: 8
# Дополнительная информация в лог # Дополнительная информация в лог
# debug-logger: on # debug-logger: on
# info-logger: on # info-logger: on
+3
View File
@@ -89,6 +89,9 @@ pack-version-code: 159
# Maximum number of packets sent to the client # Maximum number of packets sent to the client
# max-packet-sending: 150 # max-packet-sending: 150
# Additional updatable threads
threading_additional_thread_count: 8
# Additional information in the log # Additional information in the log
# debug-logger: on # debug-logger: on
# info-logger: on # info-logger: on
@@ -341,10 +341,12 @@ public class InnerCoreServer {
} }
public void start() { public void start() {
for(File file : Objects.requireNonNull(new File(InnerCoreServer.dataPath, "behavior_packs").listFiles())) { try{
BehaviorPack pack = new BehaviorPack(file.getAbsolutePath()); for(File file : Objects.requireNonNull(new File(InnerCoreServer.dataPath, "behavior_packs").listFiles())) {
pack.load(); BehaviorPack pack = new BehaviorPack(file.getAbsolutePath());
} pack.load();
}
}catch (Exception e){}
} }
public static Object getProperty(String variable) { public static Object getProperty(String variable) {
@@ -472,6 +474,10 @@ public class InnerCoreServer {
return getPropertyInt("max-packet-sending", 200); return getPropertyInt("max-packet-sending", 200);
} }
public static int getAdditionalThreadCount() {
return getPropertyInt("threading_additional_thread_count", 16);
}
public static boolean isUnsupportedOptionsAllowed() { public static boolean isUnsupportedOptionsAllowed() {
return getPropertyBoolean("allow-unsupported-options", false); return getPropertyBoolean("allow-unsupported-options", false);
} }
@@ -187,7 +187,7 @@ public class NativeCallback {
// read config and setup thread priorities // read config and setup thread priorities
private static void setupThreadPriorityFromConfig() { private static void setupThreadPriorityFromConfig() {
TickExecutor.getInstance() TickExecutor.getInstance()
.setAdditionalThreadCount(InnerCoreConfig.getInt("threading.additional_thread_count", 0)); .setAdditionalThreadCount(InnerCoreServer.getAdditionalThreadCount());
// we divide by 4 to fit into standard 1-40 priority range // we divide by 4 to fit into standard 1-40 priority range
TickExecutor.getInstance() TickExecutor.getInstance()
.setAdditionalThreadPriority(InnerCoreConfig.getInt("threading.additional_thread_priority", 12) / 4); .setAdditionalThreadPriority(InnerCoreConfig.getInt("threading.additional_thread_priority", 12) / 4);
@@ -22,7 +22,7 @@ public class TickExecutor {
} }
public void setAdditionalThreadCount(int count) { public void setAdditionalThreadCount(int count) {
count = Math.max(0, Math.min(7, count)); count = Math.max(0, Math.min(16, count));
if (threadCount != count) { if (threadCount != count) {
threadCount = count; threadCount = count;
if (executor != null) { if (executor != null) {