| 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 class FutureImpl<T> implements Future<T> { | 4 class FutureImpl<T> implements Future<T> { |
| 5 | 5 |
| 6 bool _isComplete; | 6 bool _isComplete; |
| 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 18 matching lines...) Expand all Loading... |
| 29 /** | 29 /** |
| 30 * Exception handlers waiting for exceptions. | 30 * Exception handlers waiting for exceptions. |
| 31 */ | 31 */ |
| 32 final List<Function> _exceptionHandlers; | 32 final List<Function> _exceptionHandlers; |
| 33 | 33 |
| 34 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() { | 34 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() { |
| 35 _isComplete = false; | 35 _isComplete = false; |
| 36 _exceptionHandled = false; | 36 _exceptionHandled = false; |
| 37 } | 37 } |
| 38 | 38 |
| 39 FutureImpl.immediate(T value) : this() { | 39 factory FutureImpl.immediate(T value) { |
| 40 _setValue(value); | 40 final res = new FutureImpl(); |
| 41 res._setValue(value); |
| 42 return res; |
| 41 } | 43 } |
| 42 | 44 |
| 43 T get value() { | 45 T get value() { |
| 44 if (!isComplete) { | 46 if (!isComplete) { |
| 45 throw new FutureNotCompleteException(); | 47 throw new FutureNotCompleteException(); |
| 46 } | 48 } |
| 47 if (_exception !== null) { | 49 if (_exception !== null) { |
| 48 throw _exception; | 50 throw _exception; |
| 49 } | 51 } |
| 50 return _value; | 52 return _value; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 183 } |
| 182 | 184 |
| 183 void complete(T value) { | 185 void complete(T value) { |
| 184 _futureImpl._setValue(value); | 186 _futureImpl._setValue(value); |
| 185 } | 187 } |
| 186 | 188 |
| 187 void completeException(var exception) { | 189 void completeException(var exception) { |
| 188 _futureImpl._setException(exception); | 190 _futureImpl._setException(exception); |
| 189 } | 191 } |
| 190 } | 192 } |
| OLD | NEW |