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 import "dart:_internal"; | 6 import "dart:_internal"; |
7 | 7 |
8 patch class ReceivePort { | 8 patch class ReceivePort { |
9 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 9 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
10 | 10 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 /* patch */ static Future<Isolate> spawn( | 276 /* patch */ static Future<Isolate> spawn( |
277 void entryPoint(message), var message, | 277 void entryPoint(message), var message, |
278 {bool paused: false, bool errorsAreFatal, | 278 {bool paused: false, bool errorsAreFatal, |
279 SendPort onExit, SendPort onError}) { | 279 SendPort onExit, SendPort onError}) { |
280 // `paused` isn't handled yet. | 280 // `paused` isn't handled yet. |
281 RawReceivePort readyPort; | 281 RawReceivePort readyPort; |
282 try { | 282 try { |
283 // The VM will invoke [_startIsolate] with entryPoint as argument. | 283 // The VM will invoke [_startIsolate] with entryPoint as argument. |
284 readyPort = new RawReceivePort(); | 284 readyPort = new RawReceivePort(); |
285 _spawnFunction(readyPort.sendPort, entryPoint, message, paused); | 285 _spawnFunction(readyPort.sendPort, entryPoint, message, |
| 286 paused, errorsAreFatal, onExit, onError); |
286 Completer completer = new Completer<Isolate>.sync(); | 287 Completer completer = new Completer<Isolate>.sync(); |
287 readyPort.handler = (readyMessage) { | 288 readyPort.handler = (readyMessage) { |
288 readyPort.close(); | 289 readyPort.close(); |
289 assert(readyMessage is List); | 290 assert(readyMessage is List); |
290 assert(readyMessage.length == 2); | 291 assert(readyMessage.length == 2); |
291 SendPort controlPort = readyMessage[0]; | 292 SendPort controlPort = readyMessage[0]; |
292 List capabilities = readyMessage[1]; | 293 List capabilities = readyMessage[1]; |
293 completer.complete(new Isolate(controlPort, | 294 completer.complete(new Isolate(controlPort, |
294 pauseCapability: capabilities[0], | 295 pauseCapability: capabilities[0], |
295 terminateCapability: capabilities[1])); | 296 terminateCapability: capabilities[1])); |
(...skipping 11 matching lines...) Expand all Loading... |
307 Uri uri, List<String> args, var message, | 308 Uri uri, List<String> args, var message, |
308 {bool paused: false, bool checked, Uri packageRoot, bool errorsAreFatal, | 309 {bool paused: false, bool checked, Uri packageRoot, bool errorsAreFatal, |
309 SendPort onExit, SendPort onError}) { | 310 SendPort onExit, SendPort onError}) { |
310 RawReceivePort readyPort; | 311 RawReceivePort readyPort; |
311 try { | 312 try { |
312 // The VM will invoke [_startIsolate] and not `main`. | 313 // The VM will invoke [_startIsolate] and not `main`. |
313 readyPort = new RawReceivePort(); | 314 readyPort = new RawReceivePort(); |
314 var packageRootString = | 315 var packageRootString = |
315 (packageRoot == null) ? null : packageRoot.toString(); | 316 (packageRoot == null) ? null : packageRoot.toString(); |
316 _spawnUri(readyPort.sendPort, uri.toString(), args, message, | 317 _spawnUri(readyPort.sendPort, uri.toString(), args, message, |
317 paused, checked, packageRootString); | 318 paused, checked, packageRootString, |
| 319 errorsAreFatal, onExit, onError); |
318 Completer completer = new Completer<Isolate>.sync(); | 320 Completer completer = new Completer<Isolate>.sync(); |
319 readyPort.handler = (readyMessage) { | 321 readyPort.handler = (readyMessage) { |
320 readyPort.close(); | 322 readyPort.close(); |
321 assert(readyMessage is List); | 323 assert(readyMessage is List); |
322 assert(readyMessage.length == 2); | 324 assert(readyMessage.length == 2); |
323 SendPort controlPort = readyMessage[0]; | 325 SendPort controlPort = readyMessage[0]; |
324 List capabilities = readyMessage[1]; | 326 List capabilities = readyMessage[1]; |
325 completer.complete(new Isolate(controlPort, | 327 completer.complete(new Isolate(controlPort, |
326 pauseCapability: capabilities[0], | 328 pauseCapability: capabilities[0], |
327 terminateCapability: capabilities[1])); | 329 terminateCapability: capabilities[1])); |
(...skipping 16 matching lines...) Expand all Loading... |
344 static const _PING = 3; | 346 static const _PING = 3; |
345 static const _KILL = 4; | 347 static const _KILL = 4; |
346 static const _ADD_EXIT = 5; | 348 static const _ADD_EXIT = 5; |
347 static const _DEL_EXIT = 6; | 349 static const _DEL_EXIT = 6; |
348 static const _ADD_ERROR = 7; | 350 static const _ADD_ERROR = 7; |
349 static const _DEL_ERROR = 8; | 351 static const _DEL_ERROR = 8; |
350 static const _ERROR_FATAL = 9; | 352 static const _ERROR_FATAL = 9; |
351 | 353 |
352 | 354 |
353 static void _spawnFunction(SendPort readyPort, Function topLevelFunction, | 355 static void _spawnFunction(SendPort readyPort, Function topLevelFunction, |
354 var message, bool paused) | 356 var message, bool paused, bool errorsAreFatal, |
| 357 SendPort onExit, SendPort onError) |
355 native "Isolate_spawnFunction"; | 358 native "Isolate_spawnFunction"; |
356 | 359 |
357 static void _spawnUri(SendPort readyPort, String uri, | 360 static void _spawnUri(SendPort readyPort, String uri, |
358 List<String> args, var message, | 361 List<String> args, var message, |
359 bool paused, bool checked, String packageRoot) | 362 bool paused, bool checked, String packageRoot, |
| 363 bool errorsAreFatal, SendPort onExit, SendPort onError) |
360 native "Isolate_spawnUri"; | 364 native "Isolate_spawnUri"; |
361 | 365 |
362 static void _sendOOB(port, msg) native "Isolate_sendOOB"; | 366 static void _sendOOB(port, msg) native "Isolate_sendOOB"; |
363 | 367 |
364 /* patch */ void _pause(Capability resumeCapability) { | 368 /* patch */ void _pause(Capability resumeCapability) { |
365 var msg = new List(4) | 369 var msg = new List(4) |
366 ..[0] = 0 // Make room for OOB message type. | 370 ..[0] = 0 // Make room for OOB message type. |
367 ..[1] = _PAUSE | 371 ..[1] = _PAUSE |
368 ..[2] = pauseCapability | 372 ..[2] = pauseCapability |
369 ..[3] = resumeCapability; | 373 ..[3] = resumeCapability; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 static Isolate _getCurrentIsolate() { | 449 static Isolate _getCurrentIsolate() { |
446 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); | 450 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); |
447 return new Isolate(portAndCapabilities[0], | 451 return new Isolate(portAndCapabilities[0], |
448 pauseCapability: portAndCapabilities[1], | 452 pauseCapability: portAndCapabilities[1], |
449 terminateCapability: portAndCapabilities[2]); | 453 terminateCapability: portAndCapabilities[2]); |
450 } | 454 } |
451 | 455 |
452 static List _getPortAndCapabilitiesOfCurrentIsolate() | 456 static List _getPortAndCapabilitiesOfCurrentIsolate() |
453 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; | 457 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; |
454 } | 458 } |
OLD | NEW |