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

Side by Side Diff: corelib/src/future.dart

Issue 8989015: Updates the corelib to the new default specification for interfaces and new factory syntax (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 | « corelib/src/exceptions.dart ('k') | corelib/src/implementation/hash_map_set.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart core library. 5 // Dart core library.
6 6
7 7
8 /** 8 /**
9 * A Future is used to obtain a value sometime in the 9 * A Future is used to obtain a value sometime in the
10 * future. 10 * future.
11 * 11 *
12 * Receivers of a Future obtain the value by passing 12 * Receivers of a Future obtain the value by passing
13 * a callback to the 'then' method of Future. 13 * a callback to the 'then' method of Future.
14 * 14 *
15 * For example: 15 * For example:
16 * 16 *
17 * Future<int> future = getFutureFromSomewhere(); 17 * Future<int> future = getFutureFromSomewhere();
18 * future.then((value) { 18 * future.then((value) {
19 * print("I received the number " + value); 19 * print("I received the number " + value);
20 * }); 20 * });
21 * 21 *
22 */ 22 */
23 interface Future<T> factory FutureImpl<T> { 23 interface Future<T> default FutureImpl<T> {
24 24
25 /** 25 /**
26 * The value this future provided. (If called when hasValue 26 * The value this future provided. (If called when hasValue
27 * is false, then throws an exception.) 27 * is false, then throws an exception.)
28 */ 28 */
29 T get value(); 29 T get value();
30 30
31 /** 31 /**
32 * Exception that occurred (null if no exception occured). (If called 32 * Exception that occurred (null if no exception occured). (If called
33 * before [isComplete] is true, then this exception property itself 33 * before [isComplete] is true, then this exception property itself
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * // send [future] object back to client... 87 * // send [future] object back to client...
88 * 88 *
89 * // later when value is available, call: 89 * // later when value is available, call:
90 * completer.complete(value); 90 * completer.complete(value);
91 * 91 *
92 * // alternatively, if the service cannot produce the value, it 92 * // alternatively, if the service cannot produce the value, it
93 * // can provide an exception: 93 * // can provide an exception:
94 * completer.completeException(exception); 94 * completer.completeException(exception);
95 * 95 *
96 */ 96 */
97 interface Completer<T> factory CompleterImpl<T> { 97 interface Completer<T> default CompleterImpl<T> {
98 98
99 /** Create a completer */ 99 /** Create a completer */
100 Completer(); 100 Completer();
101 101
102 Future get future(); 102 Future get future();
103 103
104 /** 104 /**
105 * Called when value is available. 105 * Called when value is available.
106 */ 106 */
107 void complete(T value); 107 void complete(T value);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 values[pos] = value; 139 values[pos] = value;
140 if (--remaining == 0) { 140 if (--remaining == 0) {
141 completer.complete(values); 141 completer.complete(values);
142 } 142 }
143 }); 143 });
144 } 144 }
145 return completer.future; 145 return completer.future;
146 } 146 }
147 } 147 }
148 148
OLDNEW
« no previous file with comments | « corelib/src/exceptions.dart ('k') | corelib/src/implementation/hash_map_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698