segment based timeout, and slowpath warning

This commit is contained in:
Leijurv
2018-09-02 13:51:38 -07:00
parent 9e272824c5
commit da5460413c
5 changed files with 22 additions and 8 deletions

View File

@@ -76,13 +76,13 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
cancelRequested = true;
}
public synchronized Optional<IPath> calculate() {
public synchronized Optional<IPath> calculate(long timeout) {
if (isFinished) {
throw new IllegalStateException("Path Finder is currently in use, and cannot be reused!");
}
this.cancelRequested = false;
try {
Optional<IPath> path = calculate0();
Optional<IPath> path = calculate0(timeout);
isFinished = true;
return path;
} catch (Exception e) {
@@ -96,7 +96,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
}
}
protected abstract Optional<IPath> calculate0();
protected abstract Optional<IPath> calculate0(long timeout);
/**
* Determines the distance squared from the specified node to the start