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

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

Issue 23534043: Don't wait for asynchronous error handlers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use _asyncSetError. Created 7 years, 3 months 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/lib/async/catch_errors15_test.dart » ('j') | tests/lib/async/catch_errors15_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/future_impl.dart
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index 4a3f064bc106c6eaf39761c59ed463e44be4f979..d639b08711e7a8dd3150228bc1f1e04f36790a84 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -181,12 +181,6 @@ class _FutureImpl<T> implements Future<T> {
static const int _VALUE = 8;
/// The future has been completed with an error result.
static const int _ERROR = 12;
- /// Extra bit set when the future has been completed with an error result.
- /// but no listener has been scheduled to receive the error.
- /// If the bit is still set when a [runAsync] call triggers, the error will
- /// be reported to the top-level handler.
- /// Assigning a listener before that time will clear the bit.
- static const int _UNHANDLED_ERROR = 16;
/** Whether the future is complete, and as what. */
int _state = _INCOMPLETE;
@@ -199,11 +193,6 @@ class _FutureImpl<T> implements Future<T> {
bool get _mayComplete => _state == _INCOMPLETE;
bool get _hasValue => _state == _VALUE;
bool get _hasError => _state >= _ERROR;
- bool get _hasUnhandledError => _state >= _UNHANDLED_ERROR;
-
- void _clearUnhandledError() {
- _state &= ~_UNHANDLED_ERROR;
- }
/**
* Either the result, a list of listeners or another future.
@@ -238,7 +227,7 @@ class _FutureImpl<T> implements Future<T> {
// Force stack trace onto error, even if it had already one.
_attachStackTrace(error, stackTrace);
}
- _setError(error);
+ _asyncSetError(error);
}
factory _FutureImpl.wait(Iterable<Future> futures) {
@@ -332,7 +321,9 @@ class _FutureImpl<T> implements Future<T> {
_resultOrListeners = error;
if (!hasListeners) {
- _scheduleUnhandledError();
+ // TODO(floitsch): Hook this into unhandled error handling.
+ var error = _resultOrListeners;
Lasse Reichstein Nielsen 2013/09/05 09:17:25 Why the alias for error here? Just remove the "var
+ _zone.handleUncaughtError(error);
return;
}
while (listeners != null) {
@@ -355,22 +346,6 @@ class _FutureImpl<T> implements Future<T> {
runAsync(() { _setErrorUnchecked(error); });
}
- void _scheduleUnhandledError() {
- assert(_state == _ERROR);
- _state = _ERROR | _UNHANDLED_ERROR;
- // Wait for the rest of the current event's duration to see
- // if a subscriber is added to handle the error.
- runAsync(() {
- if (_hasUnhandledError) {
- // No error handler has been added since the error was set.
- _clearUnhandledError();
- // TODO(floitsch): Hook this into unhandled error handling.
- var error = _resultOrListeners;
- _zone.handleUncaughtError(error);
- }
- });
- }
-
void _addListener(_FutureListener listener) {
assert(listener._nextListener == null);
if (!listener._inSameErrorZone(_zone)) {
@@ -383,7 +358,6 @@ class _FutureImpl<T> implements Future<T> {
return;
}
if (_isComplete) {
- _clearUnhandledError();
// Handle late listeners asynchronously.
runAsync(() {
if (_hasValue) {
@@ -431,7 +405,6 @@ class _FutureImpl<T> implements Future<T> {
future._setValue(_resultOrListeners);
} else {
assert(_hasError);
- _clearUnhandledError();
future._setError(_resultOrListeners);
}
}
« no previous file with comments | « no previous file | tests/lib/async/catch_errors15_test.dart » ('j') | tests/lib/async/catch_errors15_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698