9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00

fix ExecutorShutdown error, closes #44

This commit is contained in:
NONPLAYT
2025-12-14 15:11:13 +03:00
parent bd1acbc1ab
commit c74ca05912
3 changed files with 6 additions and 6 deletions

View File

@@ -9,12 +9,12 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class AsyncChunkSend { public class AsyncChunkSend {
public static final ExecutorService POOL = new ThreadPoolExecutor( public static final ExecutorService POOL = DivineConfig.AsyncCategory.asyncChunkSendingEnabled ? new ThreadPoolExecutor(
1, DivineConfig.AsyncCategory.asyncChunkSendingMaxThreads, 0L, TimeUnit.MILLISECONDS, 1, DivineConfig.AsyncCategory.asyncChunkSendingMaxThreads, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(), new LinkedBlockingQueue<>(),
new NamedAgnosticThreadFactory<>("Async Chunk Sending", AsyncChunkSendThread::new, Thread.NORM_PRIORITY), new NamedAgnosticThreadFactory<>("Async Chunk Sending", AsyncChunkSendThread::new, Thread.NORM_PRIORITY),
new ThreadPoolExecutor.CallerRunsPolicy() new ThreadPoolExecutor.CallerRunsPolicy()
); ) : null;
public static class AsyncChunkSendThread extends Thread { public static class AsyncChunkSendThread extends Thread {
protected AsyncChunkSendThread(ThreadGroup group, Runnable task, String name) { protected AsyncChunkSendThread(ThreadGroup group, Runnable task, String name) {

View File

@@ -24,14 +24,14 @@ public class AsyncPathProcessor {
private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX); private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX);
private static long lastWarnMillis = System.currentTimeMillis(); private static long lastWarnMillis = System.currentTimeMillis();
public static final ThreadPoolExecutor PATH_PROCESSING_EXECUTOR = new ThreadPoolExecutor( public static final ThreadPoolExecutor PATH_PROCESSING_EXECUTOR = DivineConfig.AsyncCategory.asyncPathfinding ? new ThreadPoolExecutor(
1, 1,
DivineConfig.AsyncCategory.asyncPathfindingMaxThreads, DivineConfig.AsyncCategory.asyncPathfindingMaxThreads,
DivineConfig.AsyncCategory.asyncPathfindingKeepalive, TimeUnit.SECONDS, DivineConfig.AsyncCategory.asyncPathfindingKeepalive, TimeUnit.SECONDS,
getQueueImpl(), getQueueImpl(),
new NamedAgnosticThreadFactory<>(THREAD_PREFIX, TickThread::new, Thread.NORM_PRIORITY - 2), new NamedAgnosticThreadFactory<>(THREAD_PREFIX, TickThread::new, Thread.NORM_PRIORITY - 2),
new RejectedTaskHandler() new RejectedTaskHandler()
); ) : null;
private static class RejectedTaskHandler implements RejectedExecutionHandler { private static class RejectedTaskHandler implements RejectedExecutionHandler {
@Override @Override

View File

@@ -29,14 +29,14 @@ public class MultithreadedTracker {
private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX); private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX);
private static long lastWarnMillis = System.currentTimeMillis(); private static long lastWarnMillis = System.currentTimeMillis();
public static final ThreadPoolExecutor TRACKER_EXECUTOR = new ThreadPoolExecutor( public static final ThreadPoolExecutor TRACKER_EXECUTOR = DivineConfig.AsyncCategory.multithreadedEnabled ? new ThreadPoolExecutor(
getCorePoolSize(), getCorePoolSize(),
getMaxPoolSize(), getMaxPoolSize(),
getKeepAliveTime(), TimeUnit.SECONDS, getKeepAliveTime(), TimeUnit.SECONDS,
getQueueImpl(), getQueueImpl(),
getThreadFactory(), getThreadFactory(),
getRejectedPolicy() getRejectedPolicy()
); ) : null;
public static void tick(ServerLevel level) { public static void tick(ServerLevel level) {
try { try {