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

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

Issue 18788002: Let completers complete in the zone they were constructed in. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move comment to correct place. Created 7 years, 5 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/standalone/io/async_catch_errors_test.dart » ('j') | no next file with comments »
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 73dc35f18cf08174f802a39fd55e7ab2e1a2d862..4a3f064bc106c6eaf39761c59ed463e44be4f979 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -23,7 +23,6 @@ abstract class _Completer<T> implements Completer<T> {
if (_isComplete) throw new StateError("Future already completed");
_isComplete = true;
_FutureImpl futureImpl = future;
- futureImpl._zone.cancelCallbackExpectation();
_setFutureValue(value);
}
@@ -35,12 +34,7 @@ abstract class _Completer<T> implements Completer<T> {
_attachStackTrace(error, stackTrace);
}
_FutureImpl futureImpl = future;
- if (futureImpl._inSameErrorZone(_Zone.current)) {
- futureImpl._zone.cancelCallbackExpectation();
- _setFutureError(error);
- } else {
- _Zone.current.handleUncaughtError(error);
- }
+ _setFutureError(error);
}
bool get isCompleted => _isComplete;
@@ -50,11 +44,17 @@ class _AsyncCompleter<T> extends _Completer<T> {
void _setFutureValue(T value) {
_FutureImpl future = this.future;
future._asyncSetValue(value);
+ // The async-error will schedule another callback, so we can cancel
+ // the expectation without shutting down the zone.
+ future._zone.cancelCallbackExpectation();
}
void _setFutureError(error) {
_FutureImpl future = this.future;
future._asyncSetError(error);
+ // The async-error will schedule another callback, so we can cancel
+ // the expectation without shutting down the zone.
+ future._zone.cancelCallbackExpectation();
}
}
@@ -62,11 +62,13 @@ class _SyncCompleter<T> extends _Completer<T> {
void _setFutureValue(T value) {
_FutureImpl future = this.future;
future._setValue(value);
+ future._zone.cancelCallbackExpectation();
}
void _setFutureError(error) {
_FutureImpl future = this.future;
future._setError(error);
+ future._zone.cancelCallbackExpectation();
}
}
« no previous file with comments | « no previous file | tests/standalone/io/async_catch_errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698