Refactor thread pool handling

This commit is contained in:
s809
2025-01-06 23:32:29 +05:00
parent fda44c41a8
commit f12f119ce2
4 changed files with 10 additions and 7 deletions
@@ -59,6 +59,7 @@ import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
#endif #endif
import java.util.HashSet; import java.util.HashSet;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
@@ -142,7 +143,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
// executor to prevent locking up the render/event thread // executor to prevent locking up the render/event thread
// if the getChunk() takes longer than expected // if the getChunk() takes longer than expected
// (which can be caused by certain mods) // (which can be caused by certain mods)
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null) if (executor != null)
{ {
executor.execute(() -> executor.execute(() ->
@@ -182,7 +183,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
// executor to prevent locking up the render/event thread // executor to prevent locking up the render/event thread
// if the getChunk() takes longer than expected // if the getChunk() takes longer than expected
// (which can be caused by certain mods) // (which can be caused by certain mods)
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null) if (executor != null)
{ {
executor.execute(() -> executor.execute(() ->
@@ -62,6 +62,7 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.lwjgl.opengl.GL32; import org.lwjgl.opengl.GL32;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
/** /**
@@ -185,7 +186,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
LevelAccessor level = event.getLevel(); LevelAccessor level = event.getLevel();
#endif #endif
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null) if (executor != null)
{ {
executor.execute(() -> executor.execute(() ->
@@ -214,7 +215,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
LevelAccessor level = event.getLevel(); LevelAccessor level = event.getLevel();
#endif #endif
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null) if (executor != null)
{ {
executor.execute(() -> executor.execute(() ->
@@ -61,6 +61,7 @@ import net.neoforged.neoforge.event.TickEvent;
#else #else
import net.neoforged.neoforge.client.event.ClientTickEvent; import net.neoforged.neoforge.client.event.ClientTickEvent;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
#endif #endif
@@ -169,7 +170,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
// executor to prevent locking up the render/event thread // executor to prevent locking up the render/event thread
// if the getChunk() takes longer than expected // if the getChunk() takes longer than expected
// (which can be caused by certain mods) // (which can be caused by certain mods)
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null) if (executor != null)
{ {
executor.execute(() -> executor.execute(() ->
@@ -196,7 +197,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
// executor to prevent locking up the render/event thread // executor to prevent locking up the render/event thread
// if the getChunk() takes longer than expected // if the getChunk() takes longer than expected
// (which can be caused by certain mods) // (which can be caused by certain mods)
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null) if (executor != null)
{ {
executor.execute(() -> executor.execute(() ->