potential thread hanging fix
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
b1c6ac6a4e
commit
76dcc4540e
@ -12,7 +12,9 @@ import electrosphere.engine.loadingthreads.LoadingThread;
|
|||||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||||
import electrosphere.entity.types.terrain.BlockChunkEntity;
|
import electrosphere.entity.types.terrain.BlockChunkEntity;
|
||||||
import electrosphere.entity.types.terrain.TerrainChunk;
|
import electrosphere.entity.types.terrain.TerrainChunk;
|
||||||
|
import electrosphere.server.ai.services.PathfindingService;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
|
import electrosphere.server.datacell.gridded.GriddedDataCellLoaderService;
|
||||||
import electrosphere.util.CodeUtils;
|
import electrosphere.util.CodeUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,9 +136,8 @@ public class ThreadManager {
|
|||||||
TerrainChunk.haltThreads();
|
TerrainChunk.haltThreads();
|
||||||
FoliageModel.haltThreads();
|
FoliageModel.haltThreads();
|
||||||
BlockChunkEntity.haltThreads();
|
BlockChunkEntity.haltThreads();
|
||||||
if(Globals.aiManager != null && Globals.aiManager.getPathfindingService() != null){
|
GriddedDataCellLoaderService.haltThreads();
|
||||||
Globals.aiManager.getPathfindingService().shutdown();
|
PathfindingService.haltThreads();
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//interrupt all threads
|
//interrupt all threads
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class PathfindingService implements AIService {
|
|||||||
/**
|
/**
|
||||||
* The executor service
|
* The executor service
|
||||||
*/
|
*/
|
||||||
ExecutorService executorService;
|
static final ExecutorService executorService = Executors.newFixedThreadPool(ThreadCounts.PATHFINDING_THREADS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues a pathfinding job
|
* Queues a pathfinding job
|
||||||
@ -31,9 +31,6 @@ public class PathfindingService implements AIService {
|
|||||||
*/
|
*/
|
||||||
public PathingProgressiveData queuePathfinding(Vector3d start, Vector3d end, VoxelPathfinder pathfinder, VoxelCellManager voxelCellManager){
|
public PathingProgressiveData queuePathfinding(Vector3d start, Vector3d end, VoxelPathfinder pathfinder, VoxelCellManager voxelCellManager){
|
||||||
PathingProgressiveData rVal = new PathingProgressiveData(end);
|
PathingProgressiveData rVal = new PathingProgressiveData(end);
|
||||||
if(executorService == null){
|
|
||||||
executorService = Executors.newFixedThreadPool(ThreadCounts.PATHFINDING_THREADS);
|
|
||||||
}
|
|
||||||
executorService.submit(() -> {
|
executorService.submit(() -> {
|
||||||
List<Vector3d> points = pathfinder.findPath(voxelCellManager, start, end, VoxelPathfinder.DEFAULT_MAX_COST);
|
List<Vector3d> points = pathfinder.findPath(voxelCellManager, start, end, VoxelPathfinder.DEFAULT_MAX_COST);
|
||||||
points.add(end);
|
points.add(end);
|
||||||
@ -50,10 +47,13 @@ public class PathfindingService implements AIService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
if(executorService != null){
|
}
|
||||||
executorService.shutdownNow();
|
|
||||||
}
|
/**
|
||||||
executorService = null;
|
* Halts all threads in the pathfinding service
|
||||||
|
*/
|
||||||
|
public static void haltThreads(){
|
||||||
|
executorService.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,5 +92,12 @@ public class GriddedDataCellLoaderService {
|
|||||||
queuedWorkLock.put(key, newJob);
|
queuedWorkLock.put(key, newJob);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Halts the threads for the data cell loader service
|
||||||
|
*/
|
||||||
|
public static void haltThreads(){
|
||||||
|
ioThreadService.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user