potential thread hanging fix
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-11 13:23:19 -04:00
parent b1c6ac6a4e
commit 76dcc4540e
3 changed files with 19 additions and 11 deletions

View File

@ -12,7 +12,9 @@ import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.types.terrain.BlockChunkEntity;
import electrosphere.entity.types.terrain.TerrainChunk;
import electrosphere.server.ai.services.PathfindingService;
import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.gridded.GriddedDataCellLoaderService;
import electrosphere.util.CodeUtils;
/**
@ -134,9 +136,8 @@ public class ThreadManager {
TerrainChunk.haltThreads();
FoliageModel.haltThreads();
BlockChunkEntity.haltThreads();
if(Globals.aiManager != null && Globals.aiManager.getPathfindingService() != null){
Globals.aiManager.getPathfindingService().shutdown();
}
GriddedDataCellLoaderService.haltThreads();
PathfindingService.haltThreads();
//
//interrupt all threads

View File

@ -19,7 +19,7 @@ public class PathfindingService implements AIService {
/**
* The executor service
*/
ExecutorService executorService;
static final ExecutorService executorService = Executors.newFixedThreadPool(ThreadCounts.PATHFINDING_THREADS);
/**
* Queues a pathfinding job
@ -31,9 +31,6 @@ public class PathfindingService implements AIService {
*/
public PathingProgressiveData queuePathfinding(Vector3d start, Vector3d end, VoxelPathfinder pathfinder, VoxelCellManager voxelCellManager){
PathingProgressiveData rVal = new PathingProgressiveData(end);
if(executorService == null){
executorService = Executors.newFixedThreadPool(ThreadCounts.PATHFINDING_THREADS);
}
executorService.submit(() -> {
List<Vector3d> points = pathfinder.findPath(voxelCellManager, start, end, VoxelPathfinder.DEFAULT_MAX_COST);
points.add(end);
@ -50,10 +47,13 @@ public class PathfindingService implements AIService {
@Override
public void shutdown() {
if(executorService != null){
executorService.shutdownNow();
}
executorService = null;
/**
* Halts all threads in the pathfinding service
*/
public static void haltThreads(){
executorService.shutdownNow();
}
}

View File

@ -93,4 +93,11 @@ public class GriddedDataCellLoaderService {
lock.unlock();
}
/**
* Halts the threads for the data cell loader service
*/
public static void haltThreads(){
ioThreadService.shutdownNow();
}
}