Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 // Dart core library. | 2 // Dart core library. |
| 3 | 3 |
| 4 class FutureImpl<T> implements Future<T> { | 4 class FutureImpl<T> implements Future<T> { |
| 5 | 5 |
| 6 bool _isComplete = false; | 6 bool _isComplete = false; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Value that was provided to this Future by the Completer | 9 * Value that was provided to this Future by the Completer |
| 10 */ | 10 */ |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 } | 204 } |
| 205 future.handleException((e) { | 205 future.handleException((e) { |
| 206 completer.completeException(e, future.stackTrace); | 206 completer.completeException(e, future.stackTrace); |
| 207 return true; | 207 return true; |
| 208 }); | 208 }); |
| 209 future.then((b) => completer.complete(b)); | 209 future.then((b) => completer.complete(b)); |
| 210 }); | 210 }); |
| 211 return completer.future; | 211 return completer.future; |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | |
| 215 class CompleterImpl<T> implements Completer<T> { | |
|
Mads Ager (google)
2012/08/01 13:48:34
Why move this to a separate file? I would leave fu
Anders Johnsen
2012/08/01 14:21:09
Reverting, see other comment.
| |
| 216 | |
| 217 final FutureImpl<T> _futureImpl; | |
| 218 | |
| 219 CompleterImpl() : _futureImpl = new FutureImpl() {} | |
| 220 | |
| 221 Future<T> get future() { | |
| 222 return _futureImpl; | |
| 223 } | |
| 224 | |
| 225 void complete(T value) { | |
| 226 _futureImpl._setValue(value); | |
| 227 } | |
| 228 | |
| 229 void completeException(Object exception, [Object stackTrace]) { | |
| 230 _futureImpl._setException(exception, stackTrace); | |
| 231 } | |
| 232 } | |
| OLD | NEW |