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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 } catch (e, st) { | 296 } catch (e, st) { |
297 if (readyPort != null) { | 297 if (readyPort != null) { |
298 readyPort.close(); | 298 readyPort.close(); |
299 } | 299 } |
300 return new Future<Isolate>.error(e, st); | 300 return new Future<Isolate>.error(e, st); |
301 }; | 301 }; |
302 } | 302 } |
303 | 303 |
304 /* patch */ static Future<Isolate> spawnUri( | 304 /* patch */ static Future<Isolate> spawnUri( |
305 Uri uri, List<String> args, var message, | 305 Uri uri, List<String> args, var message, |
306 { bool paused: false, Uri packageRoot }) { | 306 { bool paused: false, bool checked, Uri packageRoot }) { |
307 // `paused` isn't handled yet. | 307 // `paused` isn't handled yet. |
308 RawReceivePort readyPort; | 308 RawReceivePort readyPort; |
309 try { | 309 try { |
310 // The VM will invoke [_startIsolate] and not `main`. | 310 // The VM will invoke [_startIsolate] and not `main`. |
311 readyPort = new RawReceivePort(); | 311 readyPort = new RawReceivePort(); |
312 var packageRootString = | 312 var packageRootString = |
313 (packageRoot == null) ? null : packageRoot.toString(); | 313 (packageRoot == null) ? null : packageRoot.toString(); |
314 if (checked == null) { | |
315 checked = false; | |
316 assert((checked = true)); | |
Ivan Posva
2015/05/29 15:18:17
?
Lasse Reichstein Nielsen
2015/06/02 15:26:44
Just a way to get the checked-mode state of the cu
Ivan Posva
2015/06/02 17:49:31
Assertions and checked mode are two different conc
| |
317 } | |
314 _spawnUri(readyPort.sendPort, uri.toString(), args, message, | 318 _spawnUri(readyPort.sendPort, uri.toString(), args, message, |
315 paused, packageRootString); | 319 paused, checked, packageRootString); |
Ivan Posva
2015/05/29 15:18:17
Please pass the exact parameter down to the native
Lasse Reichstein Nielsen
2015/06/02 15:26:44
Done.
| |
316 Completer completer = new Completer<Isolate>.sync(); | 320 Completer completer = new Completer<Isolate>.sync(); |
317 readyPort.handler = (readyMessage) { | 321 readyPort.handler = (readyMessage) { |
318 readyPort.close(); | 322 readyPort.close(); |
319 assert(readyMessage is List); | 323 assert(readyMessage is List); |
320 assert(readyMessage.length == 2); | 324 assert(readyMessage.length == 2); |
321 SendPort controlPort = readyMessage[0]; | 325 SendPort controlPort = readyMessage[0]; |
322 List capabilities = readyMessage[1]; | 326 List capabilities = readyMessage[1]; |
323 completer.complete(new Isolate(controlPort, | 327 completer.complete(new Isolate(controlPort, |
324 pauseCapability: capabilities[0], | 328 pauseCapability: capabilities[0], |
325 terminateCapability: capabilities[1])); | 329 terminateCapability: capabilities[1])); |
(...skipping 21 matching lines...) Expand all Loading... | |
347 static const _DEL_ERROR = 8; | 351 static const _DEL_ERROR = 8; |
348 static const _ERROR_FATAL = 9; | 352 static const _ERROR_FATAL = 9; |
349 | 353 |
350 | 354 |
351 static void _spawnFunction(SendPort readyPort, Function topLevelFunction, | 355 static void _spawnFunction(SendPort readyPort, Function topLevelFunction, |
352 var message, bool paused) | 356 var message, bool paused) |
353 native "Isolate_spawnFunction"; | 357 native "Isolate_spawnFunction"; |
354 | 358 |
355 static void _spawnUri(SendPort readyPort, String uri, | 359 static void _spawnUri(SendPort readyPort, String uri, |
356 List<String> args, var message, | 360 List<String> args, var message, |
357 bool paused, String packageRoot) | 361 bool paused, bool checked, String packageRoot) |
358 native "Isolate_spawnUri"; | 362 native "Isolate_spawnUri"; |
359 | 363 |
360 static void _sendOOB(port, msg) native "Isolate_sendOOB"; | 364 static void _sendOOB(port, msg) native "Isolate_sendOOB"; |
361 | 365 |
362 /* patch */ void _pause(Capability resumeCapability) { | 366 /* patch */ void _pause(Capability resumeCapability) { |
363 var msg = new List(4) | 367 var msg = new List(4) |
364 ..[0] = 0 // Make room for OOB message type. | 368 ..[0] = 0 // Make room for OOB message type. |
365 ..[1] = _PAUSE | 369 ..[1] = _PAUSE |
366 ..[2] = pauseCapability | 370 ..[2] = pauseCapability |
367 ..[3] = resumeCapability; | 371 ..[3] = resumeCapability; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 static Isolate _getCurrentIsolate() { | 447 static Isolate _getCurrentIsolate() { |
444 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); | 448 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); |
445 return new Isolate(portAndCapabilities[0], | 449 return new Isolate(portAndCapabilities[0], |
446 pauseCapability: portAndCapabilities[1], | 450 pauseCapability: portAndCapabilities[1], |
447 terminateCapability: portAndCapabilities[2]); | 451 terminateCapability: portAndCapabilities[2]); |
448 } | 452 } |
449 | 453 |
450 static List _getPortAndCapabilitiesOfCurrentIsolate() | 454 static List _getPortAndCapabilitiesOfCurrentIsolate() |
451 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; | 455 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; |
452 } | 456 } |
OLD | NEW |