| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // Dart core library. | 2 // Dart core library. |
| 3 | 3 |
| 4 /** | |
| 5 * Thrown if client tries to obtain value or exception | |
| 6 * before a future has completed. | |
| 7 */ | |
| 8 class FutureNotCompleteException implements Exception { | |
| 9 FutureNotCompleteException() {} | |
| 10 String toString() => "Exception: future has not been completed"; | |
| 11 } | |
| 12 | |
| 13 /** | |
| 14 * Thrown if a completer tries to set the value on | |
| 15 * a future that is already complete. | |
| 16 */ | |
| 17 class FutureAlreadyCompleteException implements Exception { | |
| 18 FutureAlreadyCompleteException() {} | |
| 19 String toString() => "Exception: future already completed"; | |
| 20 } | |
| 21 | |
| 22 | |
| 23 class FutureImpl<T> implements Future<T> { | 4 class FutureImpl<T> implements Future<T> { |
| 24 | 5 |
| 25 bool _isComplete; | 6 bool _isComplete; |
| 26 | 7 |
| 27 /** | 8 /** |
| 28 * Value that was provided to this Future by the Completer | 9 * Value that was provided to this Future by the Completer |
| 29 */ | 10 */ |
| 30 T _value; | 11 T _value; |
| 31 | 12 |
| 32 /** | 13 /** |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 174 } |
| 194 | 175 |
| 195 void complete(T value) { | 176 void complete(T value) { |
| 196 _futureImpl._setValue(value); | 177 _futureImpl._setValue(value); |
| 197 } | 178 } |
| 198 | 179 |
| 199 void completeException(var exception) { | 180 void completeException(var exception) { |
| 200 _futureImpl._setException(exception); | 181 _futureImpl._setException(exception); |
| 201 } | 182 } |
| 202 } | 183 } |
| OLD | NEW |