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

Side by Side Diff: lib/core/future.dart

Issue 11238035: Make isEmpty a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 1 month 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
« no previous file with comments | « lib/core/expect.dart ('k') | lib/core/map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * A [Future] is used to obtain a value sometime in the future. Receivers of a 6 * A [Future] is used to obtain a value sometime in the future. Receivers of a
7 * [Future] can obtain the value by passing a callback to [then]. For example: 7 * [Future] can obtain the value by passing a callback to [then]. For example:
8 * 8 *
9 * Future<int> future = getFutureFromSomewhere(); 9 * Future<int> future = getFutureFromSomewhere();
10 * future.then((value) { 10 * future.then((value) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 * example, waiting for a collection of Futures to complete). 221 * example, waiting for a collection of Futures to complete).
222 */ 222 */
223 class Futures { 223 class Futures {
224 /** 224 /**
225 * Returns a future which will complete once all the futures in a list are 225 * Returns a future which will complete once all the futures in a list are
226 * complete. If any of the futures in the list completes with an exception, 226 * complete. If any of the futures in the list completes with an exception,
227 * the resulting future also completes with an exception. (The value of the 227 * the resulting future also completes with an exception. (The value of the
228 * returned future will be a list of all the values that were produced.) 228 * returned future will be a list of all the values that were produced.)
229 */ 229 */
230 static Future<List> wait(List<Future> futures) { 230 static Future<List> wait(List<Future> futures) {
231 if (futures.isEmpty()) { 231 if (futures.isEmpty) {
232 return new Future<List>.immediate(const []); 232 return new Future<List>.immediate(const []);
233 } 233 }
234 234
235 Completer completer = new Completer<List>(); 235 Completer completer = new Completer<List>();
236 Future<List> result = completer.future; 236 Future<List> result = completer.future;
237 int remaining = futures.length; 237 int remaining = futures.length;
238 List values = new List(futures.length); 238 List values = new List(futures.length);
239 239
240 // As each future completes, put its value into the corresponding 240 // As each future completes, put its value into the corresponding
241 // position in the list of values. 241 // position in the list of values.
(...skipping 11 matching lines...) Expand all
253 future.handleException((exception) { 253 future.handleException((exception) {
254 if (!result.isComplete) { 254 if (!result.isComplete) {
255 completer.completeException(exception, future.stackTrace); 255 completer.completeException(exception, future.stackTrace);
256 } 256 }
257 return true; 257 return true;
258 }); 258 });
259 } 259 }
260 return result; 260 return result;
261 } 261 }
262 } 262 }
OLDNEW
« no previous file with comments | « lib/core/expect.dart ('k') | lib/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698