Index: sdk/lib/isolate/base.dart |
diff --git a/sdk/lib/isolate/base.dart b/sdk/lib/isolate/base.dart |
index 93f8efee0bd3949b966249b045be6d9b3b12e7f0..c6c36e016f68bcb721a4669c31de0c8e14e2a5da 100644 |
--- a/sdk/lib/isolate/base.dart |
+++ b/sdk/lib/isolate/base.dart |
@@ -16,7 +16,7 @@ class IsolateSpawnException implements Exception { |
* the first communication between isolates (see [spawnFunction] and |
* [spawnUri]). |
*/ |
-external ReceivePort get port; |
+ReceivePort get port => _Isolate.port; |
/** |
* Creates and spawns an isolate that shares the same code as the current |
@@ -33,9 +33,10 @@ external ReceivePort get port; |
* |
* See comments at the top of this library for more details. |
*/ |
-// Note this feature is not yet available in the dartvm. |
-external SendPort spawnFunction(void topLevelFunction(), |
- [bool UnhandledExceptionCallback(IsolateUnhandledException e)]); |
+SendPort spawnFunction(void topLevelFunction(), |
+ [bool UnhandledExceptionCallback(IsolateUnhandledException e)]) |
+ => _Isolate.spawnFunction(topLevelFunction, UnhandledExceptionCallback); |
+ |
/** |
* Creates and spawns an isolate whose code is available at [uri]. Like with |
* [spawnFunction], the child isolate will have a default [ReceivePort], and a |
@@ -43,7 +44,7 @@ external SendPort spawnFunction(void topLevelFunction(), |
* |
* See comments at the top of this library for more details. |
*/ |
-external SendPort spawnUri(String uri); |
+SendPort spawnUri(String uri) => _Isolate.spawnUri(uri); |
/** |
* [SendPort]s are created from [ReceivePort]s. Any message sent through |
@@ -145,6 +146,16 @@ abstract class SendPortSync { |
} |
+// The VM doesn't support accessing external globals in the same library. We |
+// therefore create this wrapper class. |
+// TODO(6997): Don't go through static class for external variables. |
+abstract class _Isolate { |
+ external static ReceivePort get port; |
+ external static SendPort spawnFunction(void topLevelFunction(), |
+ [bool UnhandledExceptionCallback(IsolateUnhandledException e)]); |
+ external static SendPort spawnUri(String uri); |
+} |
+ |
/** |
* Wraps unhandled exceptions thrown during isolate execution. It is |
* used to show both the error message and the stack trace for unhandled |