public PathFinderQueue (PathFinder<N> pathFinder) { this.pathFinder = pathFinder; this.requestQueue = new CircularBuffer<PathFinderRequest<N>>(16); this.currentRequest = null; this.requestControl = new PathFinderRequestControl<N>(); }
@Override public void run (long timeToRun) { // Keep track of the current time requestControl.lastTime = TimeUtils.nanoTime(); requestControl.timeToRun = timeToRun; requestControl.timeTolerance = TIME_TOLERANCE; requestControl.pathFinder = pathFinder; requestControl.server = this; // If no search in progress, take the next from the queue if (currentRequest == null) currentRequest = requestQueue.read(); while (currentRequest != null) { boolean finished = requestControl.execute(currentRequest); if (!finished) return; // Read next request from the queue currentRequest = requestQueue.read(); } }
levelRequestControl = new PathFinderRequestControl<N>(); boolean finished = levelRequestControl.execute(levelRequest);
levelRequestControl = new PathFinderRequestControl<N>(); boolean finished = levelRequestControl.execute(levelRequest);
public PathFinderQueue (PathFinder<N> pathFinder) { this.pathFinder = pathFinder; this.requestQueue = new CircularBuffer<PathFinderRequest<N>>(16); this.currentRequest = null; this.requestControl = new PathFinderRequestControl<N>(); }
@Override public void run (long timeToRun) { // Keep track of the current time requestControl.lastTime = TimeUtils.nanoTime(); requestControl.timeToRun = timeToRun; requestControl.timeTolerance = TIME_TOLERANCE; requestControl.pathFinder = pathFinder; requestControl.server = this; // If no search in progress, take the next from the queue if (currentRequest == null) currentRequest = requestQueue.read(); while (currentRequest != null) { boolean finished = requestControl.execute(currentRequest); if (!finished) return; // Read next request from the queue currentRequest = requestQueue.read(); } }