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

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

Issue 331993005: Rewrite Zone implementation to avoid recursively looking up stuff in the parent chain. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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/schedule_microtask.dart
diff --git a/sdk/lib/async/schedule_microtask.dart b/sdk/lib/async/schedule_microtask.dart
index 7581c0abf72bd96dbe057e6572a85311f19226fc..53a0c81d6e0b06cdcd22f1bf4fb528552bbb63f7 100644
--- a/sdk/lib/async/schedule_microtask.dart
+++ b/sdk/lib/async/schedule_microtask.dart
@@ -59,11 +59,11 @@ void _scheduleAsyncCallback(callback) {
* callbacks through this method. For example the following program runs
* the callbacks without ever giving the Timer callback a chance to execute:
*
- * Timer.run(() { print("executed"); }); // Will never be executed.
- * foo() {
- * scheduleMicrotask(foo); // Schedules [foo] in front of other events.
- * }
* main() {
+ * Timer.run(() { print("executed"); }); // Will never be executed.
+ * foo() {
+ * scheduleMicrotask(foo); // Schedules [foo] in front of other events.
+ * }
* foo();
* }
*
@@ -74,10 +74,10 @@ void _scheduleAsyncCallback(callback) {
* better asynchronous code with fewer surprises.
*/
void scheduleMicrotask(void callback()) {
- if (Zone.current == Zone.ROOT) {
+ if (identical(_ROOT_ZONE, Zone.current)) {
// No need to bind the callback. We know that the root's scheduleMicrotask
// will be invoked in the root zone.
- Zone.current.scheduleMicrotask(callback);
+ _rootScheduleMicrotask(null, null, _ROOT_ZONE, callback);
return;
}
Zone.current.scheduleMicrotask(

Powered by Google App Engine
This is Rietveld 408576698