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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/status.dart

Issue 2665263002: Streamline AnalysisDriver status tracking. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 /** 7 /**
8 * The status of analysis. 8 * The status of analysis.
9 */ 9 */
10 class AnalysisStatus { 10 class AnalysisStatus {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 * Return the last status sent to the [stream]. 82 * Return the last status sent to the [stream].
83 */ 83 */
84 AnalysisStatus get currentStatus => _currentStatus; 84 AnalysisStatus get currentStatus => _currentStatus;
85 85
86 /** 86 /**
87 * Return the stream that produces [AnalysisStatus] events. 87 * Return the stream that produces [AnalysisStatus] events.
88 */ 88 */
89 Stream<AnalysisStatus> get stream => _statusController.stream; 89 Stream<AnalysisStatus> get stream => _statusController.stream;
90 90
91 /** 91 /**
92 * Prepare for the driver to start analyzing, but do not notify the [stream]
93 * yet.
94 *
95 * A call to [preTransitionToAnalyzing] has the same effect on [waitForIdle]
96 * as a call to [transitionToAnalyzing], but it has no effect on the [stream].
97 */
98 void preTransitionToAnalyzing() {
99 _idleCompleter ??= new Completer<Null>();
100 }
101
102 /**
92 * Send a notifications to the [stream] that the driver started analyzing. 103 * Send a notifications to the [stream] that the driver started analyzing.
scheglov 2017/02/01 00:35:58 Now probably that "a driver" started analyzing. Or
Paul Berry 2017/02/01 17:17:34 Done.
93 */ 104 */
94 void transitionToAnalyzing() { 105 void transitionToAnalyzing() {
95 if (_currentStatus != AnalysisStatus.ANALYZING) { 106 if (_currentStatus != AnalysisStatus.ANALYZING) {
107 preTransitionToAnalyzing();
96 _currentStatus = AnalysisStatus.ANALYZING; 108 _currentStatus = AnalysisStatus.ANALYZING;
97 _statusController.add(AnalysisStatus.ANALYZING); 109 _statusController.add(AnalysisStatus.ANALYZING);
98 } 110 }
99 } 111 }
100 112
101 /** 113 /**
102 * Send a notifications to the [stream] stream that the driver is idle. 114 * Send a notifications to the [stream] stream that the driver is idle.
103 */ 115 */
104 void transitionToIdle() { 116 void transitionToIdle() {
105 if (_currentStatus != AnalysisStatus.IDLE) { 117 if (_currentStatus != AnalysisStatus.IDLE) {
106 _currentStatus = AnalysisStatus.IDLE; 118 _currentStatus = AnalysisStatus.IDLE;
107 _statusController.add(AnalysisStatus.IDLE); 119 _statusController.add(AnalysisStatus.IDLE);
108 _idleCompleter?.complete();
109 _idleCompleter = null;
110 } 120 }
121 _idleCompleter?.complete();
122 _idleCompleter = null;
111 } 123 }
112 124
113 /** 125 /**
114 * Return a future that will be completed the next time the status is idle. 126 * Return a future that will be completed the next time the status is idle.
115 * 127 *
116 * If the status is currently idle, the returned future will be signaled 128 * If the status is currently idle, the returned future will be signaled
117 * immediately. 129 * immediately.
118 */ 130 */
119 Future<Null> waitForIdle() { 131 Future<Null> waitForIdle() {
120 if (_currentStatus == AnalysisStatus.IDLE) { 132 return _idleCompleter?.future ?? new Future.value();
121 return new Future.value();
122 } else {
123 _idleCompleter ??= new Completer<Null>();
124 return _idleCompleter.future;
125 }
126 } 133 }
127 } 134 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/test/src/dart/analysis/base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698