| 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 23 matching lines...) Expand all Loading... |
| 34 Object _exception; | 34 Object _exception; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * true, if any onException handler handled the exception. | 37 * true, if any onException handler handled the exception. |
| 38 */ | 38 */ |
| 39 bool _exceptionHandled; | 39 bool _exceptionHandled; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Listeners waiting to receive the value of this future. | 42 * Listeners waiting to receive the value of this future. |
| 43 */ | 43 */ |
| 44 final Array<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 Array<Function> _exceptionHandlers; | 49 final List<Function> _exceptionHandlers; |
| 50 | 50 |
| 51 FutureImpl() : _listeners = new Array(), _exceptionHandlers = new Array() { | 51 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() { |
| 52 _isComplete = false; | 52 _isComplete = false; |
| 53 } | 53 } |
| 54 | 54 |
| 55 T get value() { | 55 T get value() { |
| 56 if (!isComplete) { | 56 if (!isComplete) { |
| 57 throw new FutureNotCompleteException(); | 57 throw new FutureNotCompleteException(); |
| 58 } | 58 } |
| 59 if (_exception != null) { | 59 if (_exception != null) { |
| 60 throw _exception; | 60 throw _exception; |
| 61 } | 61 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 | 142 |
| 143 void complete(T value) { | 143 void complete(T value) { |
| 144 _futureImpl._setValue(value); | 144 _futureImpl._setValue(value); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void completeException(var exception) { | 147 void completeException(var exception) { |
| 148 _futureImpl._setException(exception); | 148 _futureImpl._setException(exception); |
| 149 } | 149 } |
| 150 } | 150 } |
| OLD | NEW |