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

Unified Diff: corelib/src/future.dart

Issue 9108010: Futures.wait should call then, even if some(or all) of the futures are done (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 12 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/future.dart
===================================================================
--- corelib/src/future.dart (revision 2994)
+++ corelib/src/future.dart (working copy)
@@ -135,13 +135,24 @@
// TODO(mattsh) - remove this after bug
// http://code.google.com/p/dart/issues/detail?id=333 is fixed.
int pos = i;
kasperl 2012/01/06 08:17:53 Maybe move the declaration of pos (and the TODO) d
Anders Johnsen 2012/01/06 08:57:09 Done.
- futures[pos].then((Object value) {
- values[pos] = value;
- if (--remaining == 0) {
- completer.complete(values);
- }
- });
+ if (futures[pos].isComplete) {
+ remaining--;
kasperl 2012/01/06 08:17:53 Nit: Maybe update remaining after storing the valu
Anders Johnsen 2012/01/06 08:57:09 Done.
+ values[pos] = futures[pos].value;
+ } else {
+ futures[pos].then((Object value) {
+ values[pos] = value;
+ if (--remaining == 0) {
+ completer.complete(values);
+ }
+ });
+ }
}
+ // Special case where all the futures are already completed,
+ // trigger the value now.
+ if (remaining == 0) {
+ completer.complete(values);
+ }
+
return completer.future;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698