rename ThreadPools -> ThreadPoolUtil
This commit is contained in:
@@ -32,7 +32,7 @@ import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.world.*;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
@@ -102,11 +102,11 @@ public class SharedApi
|
||||
// access the MC level at inappropriate times, which can cause exceptions
|
||||
if (currentWorld != null)
|
||||
{
|
||||
ThreadPools.setupThreadPools();
|
||||
ThreadPoolUtil.setupThreadPools();
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPools.shutdownThreadPools();
|
||||
ThreadPoolUtil.shutdownThreadPools();
|
||||
DebugRenderer.clearRenderables();
|
||||
MC_RENDER.clearTargetFrameBuffer();
|
||||
|
||||
@@ -285,7 +285,7 @@ public class SharedApi
|
||||
private static void bakeChunkLightingAndSendToLevelAsync(IChunkWrapper chunkWrapper, @Nullable ArrayList<IChunkWrapper> neighbourChunkList, IDhLevel dhLevel)
|
||||
{
|
||||
// lighting the chunk needs to be done on a separate thread to prevent lagging any of the event threads
|
||||
ThreadPoolExecutor executor = ThreadPools.getLightPopulatorExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getLightPopulatorExecutor();
|
||||
if (executor == null)
|
||||
{
|
||||
return;
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import com.seibel.distanthorizons.core.util.RenderDataPointUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.Reference;
|
||||
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -67,8 +67,8 @@ public class ColumnRenderBufferBuilder
|
||||
IDhClientLevel clientLevel, Reference<ColumnRenderBuffer> renderBufferRef,
|
||||
ColumnRenderSource renderSource, ColumnRenderSource[] adjData)
|
||||
{
|
||||
ThreadPoolExecutor bufferBuilderExecutor = ThreadPools.getBufferBuilderExecutor();
|
||||
ThreadPoolExecutor bufferUploaderExecutor = ThreadPools.getBufferUploaderExecutor();
|
||||
ThreadPoolExecutor bufferBuilderExecutor = ThreadPoolUtil.getBufferBuilderExecutor();
|
||||
ThreadPoolExecutor bufferUploaderExecutor = ThreadPoolUtil.getBufferUploaderExecutor();
|
||||
if ((bufferBuilderExecutor == null || bufferBuilderExecutor.isTerminated()) ||
|
||||
(bufferUploaderExecutor == null || bufferUploaderExecutor.isTerminated()))
|
||||
{
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataS
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -82,7 +82,7 @@ public class ChunkToLodBuilder implements AutoCloseable
|
||||
// TODO why on tick?
|
||||
public void tick()
|
||||
{
|
||||
int threadCount = ThreadPools.getWorkerThreadCount();
|
||||
int threadCount = ThreadPoolUtil.getWorkerThreadCount();
|
||||
if (this.runningCount.get() >= threadCount)
|
||||
{
|
||||
return;
|
||||
@@ -102,7 +102,7 @@ public class ChunkToLodBuilder implements AutoCloseable
|
||||
return;
|
||||
}
|
||||
|
||||
ThreadPoolExecutor lodBuilderExecutor = ThreadPools.getChunkToLodBuilderExecutor();
|
||||
ThreadPoolExecutor lodBuilderExecutor = ThreadPoolUtil.getChunkToLodBuilderExecutor();
|
||||
if (lodBuilderExecutor == null)
|
||||
{
|
||||
return;
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import com.seibel.distanthorizons.core.sql.repo.AbstractLegacyDataSourceRepo;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStream;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -128,7 +128,7 @@ public abstract class AbstractLegacyDataSourceHandler<TDataSource extends IDataS
|
||||
@Override
|
||||
public CompletableFuture<TDataSource> getAsync(DhSectionPos pos)
|
||||
{
|
||||
ThreadPoolExecutor executor = ThreadPools.getFileHandlerExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor == null || executor.isTerminated())
|
||||
{
|
||||
return CompletableFuture.completedFuture(null);
|
||||
@@ -190,7 +190,7 @@ public abstract class AbstractLegacyDataSourceHandler<TDataSource extends IDataS
|
||||
@Override
|
||||
public CompletableFuture<Void> updateDataSourceAsync(NewFullDataSource inputDataSource)
|
||||
{
|
||||
ThreadPoolExecutor executor = ThreadPools.getFileHandlerExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor == null || executor.isTerminated())
|
||||
{
|
||||
return CompletableFuture.completedFuture(null);
|
||||
|
||||
+3
-6
@@ -9,18 +9,15 @@ import com.seibel.distanthorizons.core.sql.repo.AbstractDhRepo;
|
||||
import com.seibel.distanthorizons.core.sql.dto.IBaseDTO;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -123,7 +120,7 @@ public abstract class AbstractNewDataSourceHandler
|
||||
@Override
|
||||
public CompletableFuture<TDataSource> getAsync(DhSectionPos pos)
|
||||
{
|
||||
ThreadPoolExecutor executor = ThreadPools.getFileHandlerExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor == null || executor.isTerminated())
|
||||
{
|
||||
return CompletableFuture.completedFuture(null);
|
||||
@@ -171,7 +168,7 @@ public abstract class AbstractNewDataSourceHandler
|
||||
@Override
|
||||
public CompletableFuture<Void> updateDataSourceAsync(NewFullDataSource inputDataSource)
|
||||
{
|
||||
ThreadPoolExecutor executor = ThreadPools.getFileHandlerExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor == null || executor.isTerminated())
|
||||
{
|
||||
return CompletableFuture.completedFuture(null);
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ import com.seibel.distanthorizons.core.sql.dto.NewFullDataSourceDTO;
|
||||
import com.seibel.distanthorizons.core.sql.repo.AbstractDhRepo;
|
||||
import com.seibel.distanthorizons.core.sql.repo.NewFullDataSourceRepo;
|
||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -211,7 +211,7 @@ public class NewFullDataFileHandler
|
||||
if (updatePosList.size() != 0)
|
||||
{
|
||||
// stop if the file handler has been shut down
|
||||
ThreadPoolExecutor executor = ThreadPools.getFileHandlerExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor == null || executor.isTerminated())
|
||||
{
|
||||
this.updateQueueThreadRunningRef.set(false);
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ import com.seibel.distanthorizons.core.level.IDhClientLevel;
|
||||
import com.seibel.distanthorizons.core.sql.repo.AbstractLegacyDataSourceRepo;
|
||||
import com.seibel.distanthorizons.core.sql.dto.LegacyDataSourceDTO;
|
||||
import com.seibel.distanthorizons.core.sql.repo.RenderDataRepo;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -126,7 +126,7 @@ public class RenderSourceFileHandler extends AbstractLegacyDataSourceHandler<Col
|
||||
/** Returns what should be displayed in Minecraft's F3 debug menu */
|
||||
private String[] f3Log()
|
||||
{
|
||||
ThreadPoolExecutor executor = ThreadPools.getFileHandlerExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
String queueSize = (executor != null) ? executor.getQueue().size()+"" : "-";
|
||||
String completedTaskSize = (executor != null) ? executor.getCompletedTaskCount()+"" : "-";
|
||||
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ import com.seibel.distanthorizons.core.util.LodUtil.AssertFailureException;
|
||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -446,7 +446,7 @@ public class WorldGenerationQueue implements IWorldGenerationQueue, IDebugRender
|
||||
granularity,
|
||||
targetDataDetail,
|
||||
generatorMode,
|
||||
ThreadPools.getWorldGenExecutor(),
|
||||
ThreadPoolUtil.getWorldGenExecutor(),
|
||||
(Object[] generatedObjectArray) ->
|
||||
{
|
||||
try
|
||||
@@ -472,7 +472,7 @@ public class WorldGenerationQueue implements IWorldGenerationQueue, IDebugRender
|
||||
granularity,
|
||||
targetDataDetail,
|
||||
generatorMode,
|
||||
ThreadPools.getWorldGenExecutor(),
|
||||
ThreadPoolUtil.getWorldGenExecutor(),
|
||||
(DhApiChunk dataPoints) ->
|
||||
{
|
||||
try
|
||||
@@ -572,7 +572,7 @@ public class WorldGenerationQueue implements IWorldGenerationQueue, IDebugRender
|
||||
try
|
||||
{
|
||||
int waitTimeInSeconds = 3;
|
||||
ThreadPoolExecutor executor = ThreadPools.getWorldGenExecutor();
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getWorldGenExecutor();
|
||||
if (executor != null && !executor.awaitTermination(waitTimeInSeconds, TimeUnit.SECONDS))
|
||||
{
|
||||
LOGGER.warn("World generator thread pool shutdown didn't complete after [" + waitTimeInSeconds + "] seconds. Some world generator requests may still be running.");
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.seibel.distanthorizons.core.config.listeners.ConfigChangeListener;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.util.threading.DhThreadFactory;
|
||||
import com.seibel.distanthorizons.core.util.threading.RateLimitedThreadPoolExecutor;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -33,7 +33,7 @@ import java.util.concurrent.*;
|
||||
/**
|
||||
* Handles thread pool creation.
|
||||
*
|
||||
* @see ThreadPools
|
||||
* @see ThreadPoolUtil
|
||||
* @see TimerUtil
|
||||
*/
|
||||
public class ThreadUtil
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
*
|
||||
* @see ThreadUtil
|
||||
*/
|
||||
public class ThreadPools
|
||||
public class ThreadPoolUtil
|
||||
{
|
||||
//=========================//
|
||||
// standalone thread pools //
|
||||
@@ -143,9 +143,9 @@ public class ThreadPools
|
||||
|
||||
|
||||
// worker threads
|
||||
ThreadPools.lightPopulatorThreadPool.shutdownExecutorService();
|
||||
ThreadPools.chunkToLodBuilderThreadPool.shutdownExecutorService();
|
||||
ThreadPools.bufferBuilderThreadPool.shutdownExecutorService();
|
||||
ThreadPoolUtil.lightPopulatorThreadPool.shutdownExecutorService();
|
||||
ThreadPoolUtil.chunkToLodBuilderThreadPool.shutdownExecutorService();
|
||||
ThreadPoolUtil.bufferBuilderThreadPool.shutdownExecutorService();
|
||||
|
||||
workerThreadSemaphore = null;
|
||||
|
||||
Reference in New Issue
Block a user