| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 99408df commit 926ce44
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -112,6 +112,7 @@ public PreprocessingService(JavaEditor editor) { | |||
| 112 | 112 | private void mainLoop() { | |
| 113 | 113 | running = true; | |
| 114 | 114 | PreprocessedSketch prevResult = null; | |
| 115 | + CompletableFuture<?> runningCallbacks = null; | ||
| 115 | 116 | Messages.log("PPS: Hi!"); | |
| 116 | 117 | while (running) { | |
| 117 | 118 | try { | |
@@ -126,8 +127,18 @@ private void mainLoop() { | |||
| 126 | 127 | ||
| 127 | 128 | prevResult = preprocessSketch(prevResult); | |
| 128 | 129 | ||
| 130 | + // Wait until callbacks finish before firing new wave | ||
| 131 | + // If new request arrives while waiting, break out and start preprocessing | ||
| 132 | + while (requestQueue.isEmpty() && runningCallbacks != null) { | ||
| 133 | + try { | ||
| 134 | + runningCallbacks.get(10, TimeUnit.MILLISECONDS); | ||
| 135 | + runningCallbacks = null; | ||
| 136 | + } catch (TimeoutException e) { } | ||
| 137 | + } | ||
| 138 | + | ||
| 129 | 139 | synchronized (requestLock) { | |
| 130 | 140 | if (requestQueue.isEmpty()) { | |
| 141 | + runningCallbacks = lastCallback; | ||
| 131 | 142 | Messages.log("PPS: Done"); | |
| 132 | 143 | preprocessingTask.complete(prevResult); | |
| 133 | 144 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments