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

Unified Diff: runtime/lib/isolate_patch.dart

Issue 47573002: Reland https://code.google.com/p/dart/source/detail?r=29315: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/isolate_patch.dart
===================================================================
--- runtime/lib/isolate_patch.dart (revision 29317)
+++ runtime/lib/isolate_patch.dart (working copy)
@@ -151,8 +151,6 @@
final int _id;
}
-_getPortInternal() native "isolate_getPortInternal";
-
typedef _MainFunction();
typedef _MainFunctionArgs(args);
typedef _MainFunctionArgsMessage(args, message);
@@ -161,10 +159,24 @@
* Takes the real entry point as argument and invokes it with the initial
* message.
*
- * The initial message is (currently) received through the global port variable.
+ * The initial startup message is received through the control port.
*/
void _startIsolate(Function entryPoint, bool isSpawnUri) {
- Isolate._port.first.then((message) {
+ // This port keeps the isolate alive until the initial startup message has
+ // been received.
+ var keepAlivePort = new RawReceivePort();
Ivan Posva 2013/10/27 14:33:17 This is the main change from the previously review
+
+ ignoreHandler(message) {
+ // Messages on the current Isolate's control port are dropped after the
+ // initial startup message has been received.
+ }
+
+ isolateStartHandler(message) {
+ // We received the initial startup message. Ignore all further messages and
+ // close the port which kept this isolate alive.
+ Isolate._self.handler = ignoreHandler;
+ keepAlivePort.close();
Ivan Posva 2013/10/27 14:33:17 ditto.
+
SendPort replyTo = message[0];
// TODO(floitsch): don't send ok-message if we can't find the entry point.
replyTo.send("started");
@@ -184,7 +196,9 @@
var entryMessage = message[1];
entryPoint(entryMessage);
}
- });
+ }
+
+ Isolate._self.handler = isolateStartHandler;
}
patch class Isolate {
@@ -228,11 +242,11 @@
return completer.future;
}
- static final ReceivePort _port =
- new ReceivePort.fromRawReceivePort(_getPortInternal());
+ static final RawReceivePort _self = _mainPort;
+ static RawReceivePort get _mainPort native "Isolate_mainPort";
static SendPort _spawnFunction(Function topLevelFunction)
- native "isolate_spawnFunction";
+ native "Isolate_spawnFunction";
- static SendPort _spawnUri(String uri) native "isolate_spawnUri";
+ static SendPort _spawnUri(String uri) native "Isolate_spawnUri";
}
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | runtime/vm/debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698