| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 24 entry = _nextCallback = entry.next; | 24 entry = _nextCallback = entry.next; |
| 25 } | 25 } |
| 26 // Any new callback must register a callback function now. | 26 // Any new callback must register a callback function now. |
| 27 _lastCallback = null; | 27 _lastCallback = null; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void _asyncRunCallback() { | 30 void _asyncRunCallback() { |
| 31 try { | 31 try { |
| 32 _asyncRunCallbackLoop(); | 32 _asyncRunCallbackLoop(); |
| 33 } catch (e) { | 33 } catch (e) { |
| 34 print('microtask error ${e.stackTrace}'); // TODO(efortuna): Remove this. | |
| 35 _AsyncRun._scheduleImmediate(_asyncRunCallback); | 34 _AsyncRun._scheduleImmediate(_asyncRunCallback); |
| 36 _nextCallback = _nextCallback.next; | 35 _nextCallback = _nextCallback.next; |
| 37 rethrow; | 36 rethrow; |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 void _scheduleAsyncCallback(callback) { | 40 void _scheduleAsyncCallback(callback) { |
| 42 // Optimizing a group of Timer.run callbacks to be executed in the | 41 // Optimizing a group of Timer.run callbacks to be executed in the |
| 43 // same Timer callback. | 42 // same Timer callback. |
| 44 if (_lastCallback == null) { | 43 if (_lastCallback == null) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return; | 81 return; |
| 83 } | 82 } |
| 84 Zone.current.scheduleMicrotask( | 83 Zone.current.scheduleMicrotask( |
| 85 Zone.current.bindCallback(callback, runGuarded: true)); | 84 Zone.current.bindCallback(callback, runGuarded: true)); |
| 86 } | 85 } |
| 87 | 86 |
| 88 class _AsyncRun { | 87 class _AsyncRun { |
| 89 /** Schedule the given callback before any other event in the event-loop. */ | 88 /** Schedule the given callback before any other event in the event-loop. */ |
| 90 external static void _scheduleImmediate(void callback()); | 89 external static void _scheduleImmediate(void callback()); |
| 91 } | 90 } |
| OLD | NEW |