9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 08:59:23 +00:00

move shutdown executor

This commit is contained in:
hayanesuru
2025-06-04 22:05:19 +09:00
parent 9d6e3ae5ff
commit 5ad9ec1b59
16 changed files with 81 additions and 81 deletions

View File

@@ -0,0 +1,39 @@
package org.dreeam.leaf.async;
import net.minecraft.server.MinecraftServer;
import org.dreeam.leaf.async.tracker.MultithreadedTracker;
public class ShutdownExecutors {
public static void shutdown(MinecraftServer server) {
if (server.mobSpawnExecutor != null) {
try {
server.mobSpawnExecutor.kill();
} catch (InterruptedException ignored) {
}
}
if (AsyncPlayerDataSaving.IO_POOL != null) {
AsyncPlayerDataSaving.IO_POOL.shutdown();
try {
AsyncPlayerDataSaving.IO_POOL.awaitTermination(300L, java.util.concurrent.TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
}
}
if (server.asyncGoalThread != null) {
try {
server.asyncGoalThread.join();
} catch (InterruptedException ignored) {
}
}
if (MultithreadedTracker.TRACKER_EXECUTOR != null) {
MultithreadedTracker.TRACKER_EXECUTOR.shutdown();
try {
MultithreadedTracker.TRACKER_EXECUTOR.awaitTermination(10L, java.util.concurrent.TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
}
}
}
}

View File

@@ -30,7 +30,7 @@ public class MultithreadedTracker {
private static final String THREAD_PREFIX = "Leaf Async Tracker";
private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX);
private static long lastWarnMillis = System.currentTimeMillis();
private static ThreadPoolExecutor TRACKER_EXECUTOR = null;
public static ThreadPoolExecutor TRACKER_EXECUTOR = null;
private MultithreadedTracker() {
}