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

Unified Diff: pkg/scheduled_test/test/utils.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 | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/test/utils.dart
diff --git a/pkg/scheduled_test/test/utils.dart b/pkg/scheduled_test/test/utils.dart
index 42f5c22a9b1ae84010da2af1451a37460d822996..3d59e660b81a919beef9eb52700975860a46eedc 100644
--- a/pkg/scheduled_test/test/utils.dart
+++ b/pkg/scheduled_test/test/utils.dart
@@ -20,19 +20,16 @@ export 'package:scheduled_test/src/utils.dart';
/// Note that timing out will not cancel the asynchronous operation behind
/// [input].
Future timeout(Future input, int milliseconds, onTimeout()) {
- bool completed = false;
var completer = new Completer();
var timer = new Timer(new Duration(milliseconds: milliseconds), () {
- completed = true;
- chainToCompleter(new Future.immediate(null).then((_) => onTimeout()),
- completer);
+ chainToCompleter(new Future.of(onTimeout), completer);
});
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 | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698