Chromium Code Reviews| 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 6677376eb6194c04a09169e52b31f29eb282102f..d7dc7c6969bb9dc3e5fdfef010607af56780c7d3 100644 |
| --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| @@ -70,6 +70,7 @@ import 'package:crypto/crypto.dart'; |
| * TODO(scheglov) Clean up the list of implicitly analyzed files. |
| */ |
| class AnalysisDriver { |
| + String name; |
| final PerformanceLog _logger; |
| /** |
| @@ -224,6 +225,7 @@ class AnalysisDriver { |
| try { |
| PerformanceLogSection analysisSection = null; |
| while (true) { |
| + await pumpEventQueue(100); |
|
Paul Berry
2016/10/31 20:09:39
Can you add a comment explaining why this is neede
scheglov
2016/10/31 20:37:11
Done in https://codereview.chromium.org/2466713002
|
| await _hasWork.signal; |
| if (analysisSection == null) { |
| @@ -707,6 +709,20 @@ class AnalysisDriver { |
| set.remove(element); |
| return element; |
| } |
| + |
| + /** |
| + * 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]) { |
|
Paul Berry
2016/10/31 20:09:38
Can we make this private? It seems hacky to use i
|
| + 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)); |
| + } |
| } |
| /** |