diff --git a/README-RU.md b/README-RU.md index 0e658d12f..f271bb94f 100644 --- a/README-RU.md +++ b/README-RU.md @@ -91,6 +91,9 @@ stop-on-critical-ticking-error: false # Если количесвто пакетов привышает это, то игрок кикается с сервера max-packet-sending: 200 +# Дополнительные потоки Updatable +threading_additional_thread_count: 8 + # Дополнительная информация в лог # debug-logger: on # info-logger: on diff --git a/README.md b/README.md index 47279e885..63249e428 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,9 @@ pack-version-code: 159 # Maximum number of packets sent to the client # max-packet-sending: 150 +# Additional updatable threads +threading_additional_thread_count: 8 + # Additional information in the log # debug-logger: on # info-logger: on diff --git a/src/main/java/com/reider745/InnerCoreServer.java b/src/main/java/com/reider745/InnerCoreServer.java index d3fbaae79..ec7e86323 100644 --- a/src/main/java/com/reider745/InnerCoreServer.java +++ b/src/main/java/com/reider745/InnerCoreServer.java @@ -341,10 +341,12 @@ public void reload() { } public void start() { - for(File file : Objects.requireNonNull(new File(InnerCoreServer.dataPath, "behavior_packs").listFiles())) { - BehaviorPack pack = new BehaviorPack(file.getAbsolutePath()); - pack.load(); - } + try{ + for(File file : Objects.requireNonNull(new File(InnerCoreServer.dataPath, "behavior_packs").listFiles())) { + BehaviorPack pack = new BehaviorPack(file.getAbsolutePath()); + pack.load(); + } + }catch (Exception e){} } public static Object getProperty(String variable) { @@ -472,6 +474,10 @@ public static int getMaxPacketSending(){ return getPropertyInt("max-packet-sending", 200); } + public static int getAdditionalThreadCount() { + return getPropertyInt("threading_additional_thread_count", 16); + } + public static boolean isUnsupportedOptionsAllowed() { return getPropertyBoolean("allow-unsupported-options", false); } diff --git a/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java b/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java index a2bf301cb..71e29387a 100644 --- a/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java +++ b/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java @@ -187,7 +187,7 @@ public static void onLevelCreated() { // read config and setup thread priorities private static void setupThreadPriorityFromConfig() { 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 TickExecutor.getInstance() .setAdditionalThreadPriority(InnerCoreConfig.getInt("threading.additional_thread_priority", 12) / 4); diff --git a/src/main/java/com/zhekasmirnov/innercore/api/runtime/TickExecutor.java b/src/main/java/com/zhekasmirnov/innercore/api/runtime/TickExecutor.java index 331a536b5..42ea054e3 100644 --- a/src/main/java/com/zhekasmirnov/innercore/api/runtime/TickExecutor.java +++ b/src/main/java/com/zhekasmirnov/innercore/api/runtime/TickExecutor.java @@ -22,7 +22,7 @@ public void setAdditionalThreadPriority(int priority) { } public void setAdditionalThreadCount(int count) { - count = Math.max(0, Math.min(7, count)); + count = Math.max(0, Math.min(16, count)); if (threadCount != count) { threadCount = count; if (executor != null) {