Skip to content

Commit

Permalink
Fixed: Включена многопоточность Updatable
Browse files Browse the repository at this point in the history
  • Loading branch information
Reider745 committed Jul 22, 2024
1 parent 4438da8 commit 99cbbc4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/reider745/InnerCoreServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 99cbbc4

Please sign in to comment.