Reduce CPU load when moving around the world

Should've made this multiple commits, but too late now

- Create ConfigThreadPool to remove duplicate thread setup/config code
- Move configurable thread pools into their own ThreadPools class
- Add a semaphore to limit how many LOD builder/lighting/bufferBuilder threads can be active at once
This commit is contained in:
James Seibel
2023-10-29 15:04:46 -05:00
parent 384ba30a61
commit 3f35909641
2 changed files with 4 additions and 2 deletions
@@ -27,10 +27,12 @@ import java.util.function.Consumer;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.distanthorizons.core.generation.WorldGenerationQueue;
import com.seibel.distanthorizons.core.util.ThreadUtil;
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.util.objects.EventTimer;
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import org.apache.logging.log4j.Logger;
@@ -121,7 +123,7 @@ public final class GenerationEvent
public boolean terminate()
{
LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN=======================");
WorldGenerationQueue.THREAD_FACTORY.dumpAllThreadStacks();
ThreadPools.WORLD_GEN_THREAD_FACTORY.dumpAllThreadStacks();
this.future.cancel(true);
return this.future.isCancelled();
}