Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: sdk/lib/core/future_impl.dart

Issue 11419120: Reverting 15221 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/corelib/future_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/future_impl.dart
diff --git a/sdk/lib/core/future_impl.dart b/sdk/lib/core/future_impl.dart
index 2c22e46123115e6b3dd852f5ed4fc5333f1975c7..bbae82d1667ffaff49b056c537143ee23b10d050 100644
--- a/sdk/lib/core/future_impl.dart
+++ b/sdk/lib/core/future_impl.dart
@@ -27,11 +27,6 @@ class _FutureImpl<T> implements Future<T> {
bool _exceptionHandled = false;
/**
- * true if an exception in this future should be thrown to the top level.
- */
- bool _throwOnException = false;
-
- /**
* Listeners waiting to receive the value of this future.
*/
final List<Function> _successListeners;
@@ -93,21 +88,12 @@ class _FutureImpl<T> implements Future<T> {
if (hasValue) {
onSuccess(value);
} else if (!isComplete) {
- _throwOnException = true;
_successListeners.add(onSuccess);
} else if (!_exceptionHandled) {
throw new FutureUnhandledException(_exception, stackTrace);
}
}
- void _handleSuccess(void onSuccess(T value)) {
- if (hasValue) {
- onSuccess(value);
- } else if (!isComplete) {
- _successListeners.add(onSuccess);
- }
- }
-
void handleException(bool onException(Object exception)) {
if (_exceptionHandled) return;
if (_isComplete) {
@@ -149,7 +135,7 @@ class _FutureImpl<T> implements Future<T> {
listener(value);
}
} else {
- if (!_exceptionHandled && _throwOnException) {
+ if (!_exceptionHandled && _successListeners.length > 0) {
throw new FutureUnhandledException(_exception, stackTrace);
}
}
@@ -188,7 +174,7 @@ class _FutureImpl<T> implements Future<T> {
_forwardException(this, completer);
- _handleSuccess((v) {
+ then((v) {
var transformed = null;
try {
transformed = transformation(v);
@@ -206,7 +192,7 @@ class _FutureImpl<T> implements Future<T> {
final completer = new Completer();
_forwardException(this, completer);
- _handleSuccess((v) {
+ then((v) {
var future = null;
try {
future = transformation(v);
@@ -237,10 +223,10 @@ class _FutureImpl<T> implements Future<T> {
} catch (innerException, stackTrace) {
completer.completeException(innerException, stackTrace);
}
- return false;
+ return true;
});
- _handleSuccess(completer.complete);
+ then(completer.complete);
return completer.future;
}
@@ -250,7 +236,7 @@ class _FutureImpl<T> implements Future<T> {
*/
_forward(Future future, Completer completer) {
_forwardException(future, completer);
- future._handleSuccess(completer.complete);
+ future.then(completer.complete);
}
/**
@@ -259,7 +245,7 @@ class _FutureImpl<T> implements Future<T> {
_forwardException(Future future, Completer completer) {
future.handleException((e) {
completer.completeException(e, future.stackTrace);
- return false;
+ return true;
});
}
}
« no previous file with comments | « no previous file | tests/corelib/future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698