Kill path finding jobs upon interruption, for #1873.
This commit is contained in:
parent
eeb637d59f
commit
e4ab3b0fa0
4 changed files with 31 additions and 1 deletions
|
@ -95,4 +95,11 @@ public class AIRobotMoveToBlock extends AIRobotMove {
|
|||
prevDistance = Double.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
if (pathSearchJob != null) {
|
||||
pathSearchJob.terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,4 +74,10 @@ public class AIRobotGoToRandomDirt extends AIRobot {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
if (pathFindingJob != null) {
|
||||
pathFindingJob.terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,4 +55,11 @@ public class AIRobotSearchBlock extends AIRobot {
|
|||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
if (blockScannerJob != null) {
|
||||
blockScannerJob.terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ public class PathFindingJob extends Thread {
|
|||
|
||||
private PathFinding pathFinding;
|
||||
|
||||
private boolean stop = false;
|
||||
|
||||
public PathFindingJob(PathFinding iPathFinding) {
|
||||
super("Path Finding");
|
||||
pathFinding = iPathFinding;
|
||||
|
@ -19,9 +21,17 @@ public class PathFindingJob extends Thread {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!pathFinding.isDone()) {
|
||||
while (!isTerminated() && !pathFinding.isDone()) {
|
||||
pathFinding.iterate();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void terminate() {
|
||||
stop = true;
|
||||
}
|
||||
|
||||
public synchronized boolean isTerminated() {
|
||||
return stop;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue