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

Side by Side Diff: test/dart_codegen/expect/async/schedule_microtask.dart

Issue 1148283010: Remove dart backend (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 part of dart.async;
2 typedef void _AsyncCallback();
3 class _AsyncCallbackEntry {final _AsyncCallback callback;
4 _AsyncCallbackEntry next;
5 _AsyncCallbackEntry(this.callback);
6 }
7 _AsyncCallbackEntry _nextCallback;
8 _AsyncCallbackEntry _lastCallback;
9 _AsyncCallbackEntry _lastPriorityCallback;
10 bool _isInCallbackLoop = false;
11 void _asyncRunCallbackLoop() {
12 while (_nextCallback != null) {
13 _lastPriorityCallback = null;
14 _AsyncCallbackEntry entry = _nextCallback;
15 _nextCallback = entry.next;
16 if (_nextCallback == null) _lastCallback = null;
17 entry.callback();
18 }
19 }
20 void _asyncRunCallback() {
21 _isInCallbackLoop = true;
22 try {
23 _asyncRunCallbackLoop();
24 }
25 finally {
26 _lastPriorityCallback = null;
27 _isInCallbackLoop = false;
28 if (_nextCallback != null) _AsyncRun._scheduleImmediate(_asyncRunCallback);
29 }
30 }
31 void _scheduleAsyncCallback(callback) {
32 if (_nextCallback == null) {
33 _nextCallback = _lastCallback = new _AsyncCallbackEntry(DEVC$RT.cast(callback, dynamic, _AsyncCallback, "CompositeCast", """line 66, column 61 of dart:async/s chedule_microtask.dart: """, callback is _AsyncCallback, false));
34 if (!_isInCallbackLoop) {
35 _AsyncRun._scheduleImmediate(_asyncRunCallback);
36 }
37 }
38 else {
39 _AsyncCallbackEntry newEntry = new _AsyncCallbackEntry(DEVC$RT.cast(callback, dynamic, _AsyncCallback, "CompositeCast", """line 71, column 60 of dart:async/sc hedule_microtask.dart: """, callback is _AsyncCallback, false));
40 _lastCallback.next = newEntry;
41 _lastCallback = newEntry;
42 }
43 }
44 void _schedulePriorityAsyncCallback(callback) {
45 _AsyncCallbackEntry entry = new _AsyncCallbackEntry(DEVC$RT.cast(callback, dynam ic, _AsyncCallback, "CompositeCast", """line 84, column 55 of dart:async/schedul e_microtask.dart: """, callback is _AsyncCallback, false));
46 if (_nextCallback == null) {
47 _scheduleAsyncCallback(callback);
48 _lastPriorityCallback = _lastCallback;
49 }
50 else if (_lastPriorityCallback == null) {
51 entry.next = _nextCallback;
52 _nextCallback = _lastPriorityCallback = entry;
53 }
54 else {
55 entry.next = _lastPriorityCallback.next;
56 _lastPriorityCallback.next = entry;
57 _lastPriorityCallback = entry;
58 if (entry.next == null) {
59 _lastCallback = entry;
60 }
61 }
62 }
63 void scheduleMicrotask(void callback()) {
64 if (identical(_ROOT_ZONE, Zone.current)) {
65 _rootScheduleMicrotask(null, null, _ROOT_ZONE, callback);
66 return;}
67 Zone.current.scheduleMicrotask(Zone.current.bindCallback(callback, runGuarded: true));
68 }
69 class _AsyncRun {external static void _scheduleImmediate(void callback());
70 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/async/future_impl.dart ('k') | test/dart_codegen/expect/async/stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698