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

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

Issue 11231043: Move FutureImpl and CompleterImpl from coreimpl to core, while also making them private. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/corelib_sources.gypi ('k') | lib/core/future_impl.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 11 matching lines...) Expand all
22 * called in sequence, until one returns true. 22 * called in sequence, until one returns true.
23 * 3. handlers registered with [onComplete] are called 23 * 3. handlers registered with [onComplete] are called
24 * 4. if the future failed, and at least one handler was registered with 24 * 4. if the future failed, and at least one handler was registered with
25 * [then], and no handler registered with [handleException] returned 25 * [then], and no handler registered with [handleException] returned
26 * [:true:], then the exception is thrown. 26 * [:true:], then the exception is thrown.
27 * 27 *
28 * Use a [Completer] to create and change the state of a [Future]. 28 * Use a [Completer] to create and change the state of a [Future].
29 */ 29 */
30 abstract class Future<T> { 30 abstract class Future<T> {
31 /** A future whose value is immediately available. */ 31 /** A future whose value is immediately available. */
32 factory Future.immediate(T value) => new FutureImpl<T>.immediate(value); 32 factory Future.immediate(T value) => new _FutureImpl<T>.immediate(value);
33 33
34 /** The value provided. Throws an exception if [hasValue] is false. */ 34 /** The value provided. Throws an exception if [hasValue] is false. */
35 T get value; 35 T get value;
36 36
37 /** 37 /**
38 * Exception that occurred ([:null:] if no exception occured). This property 38 * Exception that occurred ([:null:] if no exception occured). This property
39 * throws a [FutureNotCompleteException] if it is used before this future is 39 * throws a [FutureNotCompleteException] if it is used before this future is
40 * completes. 40 * completes.
41 */ 41 */
42 Object get exception; 42 Object get exception;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 * // later when value is available, call: 154 * // later when value is available, call:
155 * completer.complete(value); 155 * completer.complete(value);
156 * 156 *
157 * // alternatively, if the service cannot produce the value, it 157 * // alternatively, if the service cannot produce the value, it
158 * // can provide an exception: 158 * // can provide an exception:
159 * completer.completeException(exception); 159 * completer.completeException(exception);
160 * 160 *
161 */ 161 */
162 abstract class Completer<T> { 162 abstract class Completer<T> {
163 163
164 factory Completer() => new CompleterImpl<T>(); 164 factory Completer() => new _CompleterImpl<T>();
165 165
166 /** The future that will contain the value produced by this completer. */ 166 /** The future that will contain the value produced by this completer. */
167 Future get future; 167 Future get future;
168 168
169 /** Supply a value for [future]. */ 169 /** Supply a value for [future]. */
170 void complete(T value); 170 void complete(T value);
171 171
172 /** 172 /**
173 * Indicate in [future] that an exception occured while trying to produce its 173 * Indicate in [future] that an exception occured while trying to produce its
174 * value. The argument [exception] should not be [:null:]. A [stackTrace] 174 * value. The argument [exception] should not be [:null:]. A [stackTrace]
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/corelib_sources.gypi ('k') | lib/core/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698