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

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

Issue 11821012: Get more pub tests working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | utils/pub/io.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 /** 7 /**
8 * A [Future] is used to obtain a value sometime in the future. Receivers of a 8 * A [Future] is used to obtain a value sometime in the future. Receivers of a
9 * [Future] can obtain the value by passing a callback to [then]. For example: 9 * [Future] can obtain the value by passing a callback to [then]. For example:
10 * 10 *
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * 126 *
127 * Completer completer = new Completer(); 127 * Completer completer = new Completer();
128 * // send future object back to client... 128 * // send future object back to client...
129 * return completer.future; 129 * return completer.future;
130 * ... 130 * ...
131 * 131 *
132 * // later when value is available, call: 132 * // later when value is available, call:
133 * completer.complete(value); 133 * completer.complete(value);
134 * 134 *
135 * // alternatively, if the service cannot produce the value, it 135 * // alternatively, if the service cannot produce the value, it
136 * // can provide an exception: 136 * // can provide an error:
137 * completer.completeException(exception); 137 * completer.completeError(error);
nweiz 2013/01/09 01:24:07 You may want to at least cc Florian on this.
Bob Nystrom 2013/01/09 01:31:35 Good call. It's just a doc change, but I'll add hi
138 * 138 *
139 */ 139 */
140 abstract class Completer<T> { 140 abstract class Completer<T> {
141 141
142 factory Completer() => new _CompleterImpl<T>(); 142 factory Completer() => new _CompleterImpl<T>();
143 143
144 /** The future that will contain the result provided to this completer. */ 144 /** The future that will contain the result provided to this completer. */
145 Future get future; 145 Future get future;
146 146
147 /** 147 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 */ 185 */
186 static Future forEach(Iterable input, Future f(element)) { 186 static Future forEach(Iterable input, Future f(element)) {
187 var iterator = input.iterator; 187 var iterator = input.iterator;
188 Future nextElement(_) { 188 Future nextElement(_) {
189 if (!iterator.moveNext()) return new Future.immediate(null); 189 if (!iterator.moveNext()) return new Future.immediate(null);
190 return f(iterator.current).then(nextElement); 190 return f(iterator.current).then(nextElement);
191 } 191 }
192 return nextElement(null); 192 return nextElement(null);
193 } 193 }
194 } 194 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698