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

Unified Diff: sdk/lib/async/future.dart

Issue 14690009: Make Completers asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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: sdk/lib/async/future.dart
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index 7219719d944f713d878d11e54f0748016c9df709..53f81a2330d42bf157daa3da1dc9e9fee3121e94 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -345,6 +345,37 @@ abstract class Completer<T> {
factory Completer() => new _CompleterImpl<T>();
+ /**
+ * Completes the future synchronously.
+ *
+ * This constructor should be avoided unless the completion of the future is
+ * known to be the final result of another synchronous operation. If in doubt
Lasse Reichstein Nielsen 2013/05/06 06:49:11 synchronous -> asynchronous? (following the first
floitsch 2013/05/06 15:14:45 Done.
+ * use the default [Completer] constructor.
+ *
+ * Example:
+ *
+ * var completer = new Completer.sync();
+ * // The completion is the result of the asynchronous onDone event.
+ * // No other operation is performed after the completion. It is safe
+ * // to use the Completer.sync constructor.
+ * stream.listen(print, onDone: () { completer.complete("done"); });
+ *
+ * Bad example. Do not use this code. Only for illustrative purposes:
+ *
+ * var completer = new Completer.sync();
+ * // The completion is the result of the asynchronous onDone event.
+ * // However, there is still code executed after the completion. This
+ * // operation is *not* safe.
+ * stream.listen(print, onDone: () {
+ * completer.complete("done");
+ * foo(); // This operation follows the completion.
+ * });
+ *
+ * *WARNING* This constructor is experimental and could disappear or change
+ * behavior.
+ */
+ factory Completer.sync() => new _SyncCompleterImpl<T>();
+
/** The future that will contain the result provided to this completer. */
Future get future;

Powered by Google App Engine
This is Rietveld 408576698