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

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

Issue 11312122: Change List constructors. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload. Adapt code for List.fixedLength. Created 8 years 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 | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | sdk/lib/core/list.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 // part of dart_async; 5 // part of dart_async;
6 6
7 deprecatedFutureValue(_FutureImpl future) => future._resultOrListeners; 7 deprecatedFutureValue(_FutureImpl future) => future._resultOrListeners;
8 8
9 9
10 class _CompleterImpl<T> implements Completer<T> { 10 class _CompleterImpl<T> implements Completer<T> {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 factory _FutureImpl.wait(Iterable<Future> futures) { 81 factory _FutureImpl.wait(Iterable<Future> futures) {
82 // TODO(ajohnsen): can we do better wrt the generic type T? 82 // TODO(ajohnsen): can we do better wrt the generic type T?
83 if (futures.isEmpty) { 83 if (futures.isEmpty) {
84 return new Future<List>.immediate(const []); 84 return new Future<List>.immediate(const []);
85 } 85 }
86 86
87 Completer completer = new Completer<List>(); 87 Completer completer = new Completer<List>();
88 int remaining = futures.length; 88 int remaining = futures.length;
89 List values = new List(futures.length); 89 List values = new List.fixedLength(futures.length);
90 90
91 // As each future completes, put its value into the corresponding 91 // As each future completes, put its value into the corresponding
92 // position in the list of values. 92 // position in the list of values.
93 int i = 0; 93 int i = 0;
94 for (Future future in futures) { 94 for (Future future in futures) {
95 int pos = i++; 95 int pos = i++;
96 future.then((Object value) { 96 future.then((Object value) {
97 values[pos] = value; 97 values[pos] = value;
98 if (--remaining == 0) { 98 if (--remaining == 0) {
99 completer.complete(values); 99 completer.complete(values);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 _FutureWrapper(this._future); 371 _FutureWrapper(this._future);
372 372
373 Future then(function(T value)) => _future.then(function); 373 Future then(function(T value)) => _future.then(function);
374 Future catchError(function(AsyncError error), {bool test(var error)}) { 374 Future catchError(function(AsyncError error), {bool test(var error)}) {
375 return _future.catchError(function, test: test); 375 return _future.catchError(function, test: test);
376 } 376 }
377 Future subscribe({onValue(T value), onError(AsyncError error)}) { 377 Future subscribe({onValue(T value), onError(AsyncError error)}) {
378 _future.subscribe(onValue: onValue, onError: onError); 378 _future.subscribe(onValue: onValue, onError: onError);
379 } 379 }
380 } 380 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698