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

Unified Diff: utils/pub/io.dart

Issue 12385027: Make use of Completer.isComplete in pub and pkg/scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/scheduled_test/test/utils.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index a8ec15891557bcbc5d9f96e9bbbe13b0035bdb4f..8ca26545fab02644e3c2a5c7b1dcc878fb5b9009 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -591,19 +591,17 @@ Future _doProcess(Function fn, String executable, List<String> args,
/// Note that timing out will not cancel the asynchronous operation behind
/// [input].
Future timeout(Future input, int milliseconds, String description) {
- bool completed = false;
var completer = new Completer();
var timer = new Timer(new Duration(milliseconds: milliseconds), () {
- completed = true;
completer.completeError(new TimeoutException(
'Timed out while $description.'));
});
input.then((value) {
- if (completed) return;
+ if (completer.isCompleted) return;
timer.cancel();
completer.complete(value);
}).catchError((e) {
- if (completed) return;
+ if (completer.isCompleted) return;
timer.cancel();
completer.completeError(e.error, e.stackTrace);
});
« no previous file with comments | « pkg/scheduled_test/test/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698