| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "dart:collection" show HashMap; | 5 import "dart:collection" show HashMap; |
| 6 | 6 |
| 7 patch class ReceivePort { | 7 patch class ReceivePort { |
| 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 9 | 9 |
| 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = | 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 // Forward the implementation of sending messages to the VM. | 174 // Forward the implementation of sending messages to the VM. |
| 175 void _sendInternal(var message) native "SendPortImpl_sendInternal_"; | 175 void _sendInternal(var message) native "SendPortImpl_sendInternal_"; |
| 176 } | 176 } |
| 177 | 177 |
| 178 typedef _MainFunction(); | 178 typedef _MainFunction(); |
| 179 typedef _MainFunctionArgs(args); | 179 typedef _MainFunctionArgs(args); |
| 180 typedef _MainFunctionArgsMessage(args, message); | 180 typedef _MainFunctionArgsMessage(args, message); |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * Takes the real entry point as argument and invokes it with the |
| 184 * initial message. Defers execution of the entry point until the |
| 185 * isolate is in the message loop. |
| 186 */ |
| 187 void _startMainIsolate(Function entryPoint, |
| 188 List<String> args) { |
| 189 RawReceivePort port = new RawReceivePort(); |
| 190 port.handler = (_) { |
| 191 port.close(); |
| 192 _startIsolate(null, // no parent port |
| 193 entryPoint, |
| 194 args, |
| 195 null, // no message |
| 196 true, // isSpawnUri |
| 197 null, // no control port |
| 198 null); // no capabilities |
| 199 }; |
| 200 port.sendPort.send(null); |
| 201 } |
| 202 |
| 203 /** |
| 183 * Takes the real entry point as argument and invokes it with the initial | 204 * Takes the real entry point as argument and invokes it with the initial |
| 184 * message. | 205 * message. |
| 185 * | |
| 186 * The initial startup message is received through the control port. | |
| 187 */ | 206 */ |
| 188 void _startIsolate(SendPort parentPort, | 207 void _startIsolate(SendPort parentPort, |
| 189 Function entryPoint, | 208 Function entryPoint, |
| 190 List<String> args, | 209 List<String> args, |
| 191 var message, | 210 var message, |
| 192 bool isSpawnUri, | 211 bool isSpawnUri, |
| 193 RawReceivePort controlPort, | 212 RawReceivePort controlPort, |
| 194 List capabilities) { | 213 List capabilities) { |
| 195 if (controlPort != null) { | 214 if (controlPort != null) { |
| 196 controlPort.handler = (_) {}; // Nobody home on the control port. | 215 controlPort.handler = (_) {}; // Nobody home on the control port. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 357 } |
| 339 | 358 |
| 340 /* patch */ void addErrorListener(SendPort port) { | 359 /* patch */ void addErrorListener(SendPort port) { |
| 341 throw new UnsupportedError("addErrorListener"); | 360 throw new UnsupportedError("addErrorListener"); |
| 342 } | 361 } |
| 343 | 362 |
| 344 /* patch */ void removeErrorListener(SendPort port) { | 363 /* patch */ void removeErrorListener(SendPort port) { |
| 345 throw new UnsupportedError("removeErrorListener"); | 364 throw new UnsupportedError("removeErrorListener"); |
| 346 } | 365 } |
| 347 } | 366 } |
| OLD | NEW |