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

Side by Side Diff: sdk/lib/async/schedule_microtask.dart

Issue 637893002: Use a _FutureListener separate from the _Future to hold listeners. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | sdk/lib/async/zone.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 typedef void _AsyncCallback(); 7 typedef void _AsyncCallback();
8 8
9 class _AsyncCallbackEntry { 9 class _AsyncCallbackEntry {
10 final _AsyncCallback callback; 10 final _AsyncCallback callback;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 /** 77 /**
78 * Schedules a callback to be called before all other currently scheduled ones. 78 * Schedules a callback to be called before all other currently scheduled ones.
79 * 79 *
80 * This callback takes priority over existing scheduled callbacks. 80 * This callback takes priority over existing scheduled callbacks.
81 * It is only used internally to give higher priority to error reporting. 81 * It is only used internally to give higher priority to error reporting.
82 */ 82 */
83 void _schedulePriorityAsyncCallback(callback) { 83 void _schedulePriorityAsyncCallback(callback) {
84 _AsyncCallbackEntry entry = new _AsyncCallbackEntry(callback); 84 _AsyncCallbackEntry entry = new _AsyncCallbackEntry(callback);
85 if (_nextCallback == null) { 85 if (_nextCallback == null) {
86 _nextCallback = _lastCallback = _lastPriorityCallback = entry; 86 _scheduleAsyncCallback(callback);
87 if (!_isInCallbackLoop) { 87 _lastPriorityCallback = _lastCallback;
88 _AsyncRun._scheduleImmediate(_asyncRunCallback);
89 }
90 } else if (_lastPriorityCallback == null) { 88 } else if (_lastPriorityCallback == null) {
91 entry.next = _nextCallback; 89 entry.next = _nextCallback;
92 _nextCallback = _lastPriorityCallback = entry; 90 _nextCallback = _lastPriorityCallback = entry;
93 } else { 91 } else {
94 entry.next = _lastPriorityCallback.next; 92 entry.next = _lastPriorityCallback.next;
95 _lastPriorityCallback.next = entry; 93 _lastPriorityCallback.next = entry;
96 _lastPriorityCallback = entry; 94 _lastPriorityCallback = entry;
97 if (entry.next == null) { 95 if (entry.next == null) {
98 _lastCallback = entry; 96 _lastCallback = entry;
99 } 97 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return; 131 return;
134 } 132 }
135 Zone.current.scheduleMicrotask( 133 Zone.current.scheduleMicrotask(
136 Zone.current.bindCallback(callback, runGuarded: true)); 134 Zone.current.bindCallback(callback, runGuarded: true));
137 } 135 }
138 136
139 class _AsyncRun { 137 class _AsyncRun {
140 /** Schedule the given callback before any other event in the event-loop. */ 138 /** Schedule the given callback before any other event in the event-loop. */
141 external static void _scheduleImmediate(void callback()); 139 external static void _scheduleImmediate(void callback());
142 } 140 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | sdk/lib/async/zone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698