Index: pkg/analyzer/lib/src/dart/analysis/driver.dart |
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
index 647e3992f89d2e29a922f81e5b58fe8a0b3dae93..1b7140c490495e5e9b0d419ad044440631e675f4 100644 |
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart |
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
@@ -231,7 +231,17 @@ class AnalysisDriver { |
try { |
PerformanceLogSection analysisSection = null; |
while (true) { |
- await pumpEventQueue(100); |
+ // Pump the event queue to allow IO and other asynchronous data |
+ // processing while analysis is active. For example Analysis Server |
+ // needs to be able to process `updateContent` or `setPriorityFiles` |
+ // requests while background analysis is in progress. |
+ // |
+ // The number of pumpings is arbitrary, might be changed if we see that |
+ // analysis or other data processing tasks are starving. Ideally we |
+ // would need to be able to set priority of (continuous) asynchronous |
+ // tasks. |
+ await _pumpEventQueue(128); |
+ |
await _hasWork.signal; |
if (analysisSection == null) { |
@@ -385,20 +395,6 @@ class AnalysisDriver { |
} |
/** |
- * Returns a [Future] that completes after pumping the event queue [times] |
- * times. By default, this should pump the event queue enough times to allow |
- * any code to run, as long as it's not waiting on some external event. |
- */ |
- Future pumpEventQueue([int times = 5000]) { |
- if (times == 0) return new Future.value(); |
- // We use a delayed future to allow microtask events to finish. The |
- // Future.value or Future() constructors use scheduleMicrotask themselves and |
- // would therefore not wait for microtask callbacks that are scheduled after |
- // invoking this method. |
- return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); |
- } |
- |
- /** |
* Remove the file with the given [path] from the list of files to analyze. |
* |
* The [path] must be absolute and normalized. |
@@ -733,6 +729,17 @@ class AnalysisDriver { |
} |
/** |
+ * Returns a [Future] that completes after performing [times] pumpings of |
+ * the event queue. |
+ */ |
+ static Future _pumpEventQueue(int times) { |
+ if (times == 0) { |
+ return new Future.value(); |
+ } |
+ return new Future.delayed(Duration.ZERO, () => _pumpEventQueue(times - 1)); |
+ } |
+ |
+ /** |
* Remove and return the first item in the given [set]. |
*/ |
static Object/*=T*/ _removeFirst/*<T>*/(LinkedHashSet<Object/*=T*/ > set) { |