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

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: 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
Index: sdk/lib/async/future_impl.dart
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index be0b7a23229fff9d0acee3ff592698f11332e542..738a9bba9aa368a0f5ce12bbac26820c7118fe2d 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -10,9 +10,11 @@ deprecatedFutureValue(_FutureImpl future) =>
abstract class _Completer<T> implements Completer<T> {
final Future<T> future;
Anders Johnsen 2013/07/05 17:10:50 It's okay to type this _FutureImpl, and then avoid
floitsch 2013/07/05 18:08:19 I think I once had a _FutureImpl here, but Lasse a
Lasse Reichstein Nielsen 2013/07/05 18:49:43 The argument was that is that the field is public,
bool _isComplete = false;
+ final _Zone _zone = _Zone.current.fork();
_Completer() : future = new _FutureImpl<T>() {
Anders Johnsen 2013/07/05 17:10:50 So Future have a Zone too, so why not just use tha
floitsch 2013/07/05 18:08:19 Right... No need for Zones in the completer. Remov
Lasse Reichstein Nielsen 2013/07/05 18:49:43 My interpretation too. Can't you just use future._
floitsch 2013/07/05 18:51:46 Completer.zone is already removed.
_FutureImpl futureImpl = future;
+ _zone.expectCallback();
futureImpl._zone.expectCallback();
}
@@ -23,6 +25,7 @@ abstract class _Completer<T> implements Completer<T> {
if (_isComplete) throw new StateError("Future already completed");
_isComplete = true;
_FutureImpl futureImpl = future;
+ _zone.cancelCallbackExpectation();
futureImpl._zone.cancelCallbackExpectation();
_setFutureValue(value);
}
@@ -35,11 +38,13 @@ abstract class _Completer<T> implements Completer<T> {
_attachStackTrace(error, stackTrace);
}
_FutureImpl futureImpl = future;
- if (futureImpl._inSameErrorZone(_Zone.current)) {
+ if (futureImpl._inSameErrorZone(_zone)) {
Anders Johnsen 2013/07/05 17:10:50 futureImpl._zone and below?
floitsch 2013/07/05 18:08:19 Actually it must be the same zone now, so I could
+ _zone.cancelCallbackExpectation();
futureImpl._zone.cancelCallbackExpectation();
_setFutureError(error);
} else {
- _Zone.current.handleUncaughtError(error);
+ _zone.cancelCallbackExpectation();
+ _zone.handleUncaughtError(error);
}
}
« no previous file with comments | « no previous file | tests/standalone/io/async_catch_errors_test.dart » ('j') | tests/standalone/io/async_catch_errors_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698