Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 875163002: Make AnalysisServer.onAnalysisComplete a Future and wait for it before refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Completer instead of busy loop Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 139048371770a77bb839b809f3741ae7d531782b..884fc91c366f8b360c70d6a3908521f005078219 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -172,14 +172,14 @@ class AnalysisServer {
bool _noErrorNotification;
/**
- * The controller that is notified when analysis is started.
+ * The [Completer] that completes when analysis is complete.
*/
- StreamController<AnalysisContext> _onAnalysisStartedController;
+ Completer _onAnalysisCompleteCompleter;
/**
- * The controller that is notified when analysis is complete.
+ * The controller that is notified when analysis is started.
*/
- StreamController _onAnalysisCompleteController;
+ StreamController<AnalysisContext> _onAnalysisStartedController;
/**
* The controller that is notified when a single file has been analyzed.
@@ -231,7 +231,6 @@ class AnalysisServer {
_noErrorNotification = analysisServerOptions.noErrorNotification;
AnalysisEngine.instance.logger = new AnalysisLogger();
_onAnalysisStartedController = new StreamController.broadcast();
- _onAnalysisCompleteController = new StreamController.broadcast();
_onFileAnalyzedController = new StreamController.broadcast();
_onPriorityChangeController =
new StreamController<PriorityChangeEvent>.broadcast();
@@ -242,9 +241,17 @@ class AnalysisServer {
}
/**
- * The stream that is notified when analysis is complete.
+ * The [Future] that completes when analysis is complete.
*/
- Stream get onAnalysisComplete => _onAnalysisCompleteController.stream;
+ Future get onAnalysisComplete {
+ if (isAnalysisComplete()) {
+ return new Future.value();
+ }
+ if (_onAnalysisCompleteCompleter == null) {
+ _onAnalysisCompleteCompleter = new Completer();
+ }
+ return _onAnalysisCompleteCompleter.future;
+ }
/**
* The stream that is notified when analysis of a context is started.
@@ -632,7 +639,10 @@ class AnalysisServer {
_schedulePerformOperation();
} else {
sendStatusNotification(null);
- _onAnalysisCompleteController.add(null);
+ if (_onAnalysisCompleteCompleter != null) {
+ _onAnalysisCompleteCompleter.complete();
+ _onAnalysisCompleteCompleter = null;
+ }
}
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698