| 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 /** | 4 /** |
| 5 * Thrown if client tries to obtain value or exception | 5 * Thrown if client tries to obtain value or exception |
| 6 * before a future has completed. | 6 * before a future has completed. |
| 7 */ | 7 */ |
| 8 class FutureNotCompleteException implements Exception { | 8 class FutureNotCompleteException implements Exception { |
| 9 FutureNotCompleteException() {} | 9 FutureNotCompleteException() {} |
| 10 } | 10 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 */ | 43 */ |
| 44 final List<Function> _listeners; | 44 final List<Function> _listeners; |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Exception handlers waiting for exceptions. | 47 * Exception handlers waiting for exceptions. |
| 48 */ | 48 */ |
| 49 final List<Function> _exceptionHandlers; | 49 final List<Function> _exceptionHandlers; |
| 50 | 50 |
| 51 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() { | 51 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() { |
| 52 _isComplete = false; | 52 _isComplete = false; |
| 53 _exceptionHandled = false; |
| 53 } | 54 } |
| 54 | 55 |
| 55 T get value() { | 56 T get value() { |
| 56 if (!isComplete) { | 57 if (!isComplete) { |
| 57 throw new FutureNotCompleteException(); | 58 throw new FutureNotCompleteException(); |
| 58 } | 59 } |
| 59 if (_exception != null) { | 60 if (_exception != null) { |
| 60 throw _exception; | 61 throw _exception; |
| 61 } | 62 } |
| 62 return _value; | 63 return _value; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 142 } |
| 142 | 143 |
| 143 void complete(T value) { | 144 void complete(T value) { |
| 144 _futureImpl._setValue(value); | 145 _futureImpl._setValue(value); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void completeException(var exception) { | 148 void completeException(var exception) { |
| 148 _futureImpl._setException(exception); | 149 _futureImpl._setException(exception); |
| 149 } | 150 } |
| 150 } | 151 } |
| OLD | NEW |