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

Side by Side Diff: sdk/lib/async/future.dart

Issue 23875032: Expose Zones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark stack trace test as failing. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart.async; 5 part of dart.async;
6 6
7 /** 7 /**
8 * An object representing a delayed computation. 8 * An object representing a delayed computation.
9 * 9 *
10 * A [Future] is used to obtain a not yet 10 * A [Future] is used to obtain a not yet
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 * Returns a future which will complete once all the futures in a list are 187 * Returns a future which will complete once all the futures in a list are
188 * complete. If any of the futures in the list completes with an error, 188 * complete. If any of the futures in the list completes with an error,
189 * the resulting future also completes with an error. Otherwise the value 189 * the resulting future also completes with an error. Otherwise the value
190 * of the returned future will be a list of all the values that were produced. 190 * of the returned future will be a list of all the values that were produced.
191 */ 191 */
192 static Future<List> wait(Iterable<Future> futures) { 192 static Future<List> wait(Iterable<Future> futures) {
193 Completer completer; 193 Completer completer;
194 // List collecting values from the futures. 194 // List collecting values from the futures.
195 // Set to null if an error occurs. 195 // Set to null if an error occurs.
196 List values; 196 List values;
197 void handleError(error) { 197
198 handleError(error) {
Lasse Reichstein Nielsen 2013/09/23 14:24:12 Without the "void" this looks too much like a func
floitsch 2013/09/23 17:12:07 It sticks nicely out in the editor. So syntax high
198 if (values != null) { 199 if (values != null) {
199 values = null; 200 values = null;
200 completer.completeError(error); 201 completer.completeError(error);
201 } 202 }
203 return null;
202 } 204 }
205
203 // As each future completes, put its value into the corresponding 206 // As each future completes, put its value into the corresponding
204 // position in the list of values. 207 // position in the list of values.
205 int remaining = 0; 208 int remaining = 0;
206 for (Future future in futures) { 209 for (Future future in futures) {
207 int pos = remaining++; 210 int pos = remaining++;
208 future.catchError(handleError).then((Object value) { 211 future.catchError(handleError).then((Object value) {
209 if (values == null) return null; 212 if (values == null) return null;
210 values[pos] = value; 213 values[pos] = value;
211 remaining--; 214 remaining--;
212 if (remaining == 0) { 215 if (remaining == 0) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 * 468 *
466 * The argument [exception] must not be `null`. 469 * The argument [exception] must not be `null`.
467 */ 470 */
468 void completeError(Object exception, [Object stackTrace]); 471 void completeError(Object exception, [Object stackTrace]);
469 472
470 /** 473 /**
471 * Whether the future has been completed. 474 * Whether the future has been completed.
472 */ 475 */
473 bool get isCompleted; 476 bool get isCompleted;
474 } 477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698