Index: sdk/lib/async/future_impl.dart |
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart |
index 3660b9ff8830910280bcf7b639f976fec9f9ca52..4e9b1d959f9b418099574cb0fdb876532cc42d98 100644 |
--- a/sdk/lib/async/future_impl.dart |
+++ b/sdk/lib/async/future_impl.dart |
@@ -7,17 +7,20 @@ part of dart.async; |
deprecatedFutureValue(_FutureImpl future) => |
future._isComplete ? future._resultOrListeners : null; |
-class _CompleterImpl<T> implements Completer<T> { |
- final Future<T> future; |
+abstract class _Completer<T> implements Completer<T> { |
+ final _FutureImpl<T> future; |
Lasse Reichstein Nielsen
2013/05/06 06:49:11
_FutureImpl -> Future. No reason to change the typ
floitsch
2013/05/06 15:14:45
Done.
|
bool _isComplete = false; |
- _CompleterImpl() : future = new _FutureImpl<T>(); |
+ _Completer() : future = new _FutureImpl<T>(); |
+ |
+ void _setFutureValue(T value); |
+ void _setFutureError(error); |
void complete([T value]) { |
if (_isComplete) throw new StateError("Future already completed"); |
_isComplete = true; |
_FutureImpl future = this.future; |
Lasse Reichstein Nielsen
2013/05/06 06:49:11
Move this cast to _setFutureValue.
floitsch
2013/05/06 15:14:45
Done.
|
- future._setValue(value); |
+ _setFutureValue(value); |
} |
void completeError(Object error, [Object stackTrace = null]) { |
@@ -28,12 +31,32 @@ class _CompleterImpl<T> implements Completer<T> { |
_attachStackTrace(error, stackTrace); |
} |
_FutureImpl future = this.future; |
Lasse Reichstein Nielsen
2013/05/06 06:49:11
And remove this one.
floitsch
2013/05/06 15:14:45
Done.
|
- future._setError(error); |
+ _setFutureError(error); |
} |
bool get isCompleted => _isComplete; |
} |
+class _CompleterImpl<T> extends _Completer<T> { |
Lasse Reichstein Nielsen
2013/05/06 06:49:11
I prefer _AsyncCompleter (and _SyncCompleter below
floitsch
2013/05/06 15:14:45
Done.
|
+ void _setFutureValue(T value) { |
+ runAsync(() { future._setValue(value); }); |
+ } |
+ |
+ void _setFutureError(error) { |
+ runAsync(() { future._setError(error); }); |
+ } |
+} |
+ |
+class _SyncCompleterImpl<T> extends _Completer<T> { |
+ void _setFutureValue(T value) { |
+ future._setValue(value); |
+ } |
+ |
+ void _setFutureError(error) { |
+ future._setError(error); |
+ } |
+} |
+ |
/** |
* A listener on a future. |
* |