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. |