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

Unified Diff: runtime/lib/isolate_patch.dart

Issue 79243002: Implement scheduleImmediate for the VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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: runtime/lib/isolate_patch.dart
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index 46e4f4039fb0280e74acec775d4b2dd9a71c2e31..b8c01663d6b82f50363f871b673fc91bba43029b 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -57,6 +57,15 @@ class _ReceivePortImpl extends Stream implements ReceivePort {
StreamController _controller;
}
+var _pendingImmediateCallback;
floitsch 2013/11/20 19:37:13 Not yet typed. Will do that.
floitsch 2013/11/21 17:39:47 Done.
+void _isolateScheduleImmediate(void callback()) {
+ assert(_pendingImmediateCallback == null);
+ _pendingImmediateCallback = callback;
+}
+Function _getIsolateScheduleImmediateClosure() {
floitsch 2013/11/20 19:37:13 ditto.
floitsch 2013/11/21 17:39:47 In the end didn't type it. It's only used for the
+ return _isolateScheduleImmediate;
+}
+
class _RawReceivePortImpl implements RawReceivePort {
factory _RawReceivePortImpl() native "RawReceivePortImpl_factory";
@@ -92,7 +101,15 @@ class _RawReceivePortImpl implements RawReceivePort {
static void _handleMessage(
_RawReceivePortImpl port, int replyId, var message) {
assert(port != null);
+ // TODO(floitsch): this relies on the fact that any exception aborts the
+ // VM. Once we have non-fatal global exceptions we need to catch errors
+ // so that we can run the immediate callbacks.
port._handler(message);
+ if (_pendingImmediateCallback != null) {
+ var callback = _pendingImmediateCallback;
+ _pendingImmediateCallback = null;
+ callback();
+ }
}
// Call into the VM to close the VM maintained mappings.

Powered by Google App Engine
This is Rietveld 408576698