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:
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user