| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 readyPort.close(); | 270 readyPort.close(); |
| 271 } | 271 } |
| 272 return new Future<Isolate>.error(e, st); | 272 return new Future<Isolate>.error(e, st); |
| 273 }; | 273 }; |
| 274 } | 274 } |
| 275 | 275 |
| 276 /* patch */ static Future<Isolate> spawnUri( | 276 /* patch */ static Future<Isolate> spawnUri( |
| 277 Uri uri, List<String> args, var message, | 277 Uri uri, List<String> args, var message, |
| 278 { bool paused: false, Uri packageRoot }) { | 278 { bool paused: false, Uri packageRoot }) { |
| 279 // `paused` isn't handled yet. | 279 // `paused` isn't handled yet. |
| 280 // `packageRoot` isn't handled yet. |
| 281 if (packageRoot != null) throw new UnimplementedError("packageRoot"); |
| 280 RawReceivePort readyPort; | 282 RawReceivePort readyPort; |
| 281 try { | 283 try { |
| 282 // The VM will invoke [_startIsolate] and not `main`. | 284 // The VM will invoke [_startIsolate] and not `main`. |
| 283 readyPort = new RawReceivePort(); | 285 readyPort = new RawReceivePort(); |
| 284 var packageRootString = | 286 _spawnUri(readyPort.sendPort, uri.toString(), args, message); |
| 285 (packageRoot == null) ? null : packageRoot.toString(); | |
| 286 _spawnUri( | |
| 287 readyPort.sendPort, uri.toString(), args, message, packageRootString); | |
| 288 Completer completer = new Completer<Isolate>.sync(); | 287 Completer completer = new Completer<Isolate>.sync(); |
| 289 readyPort.handler = (readyMessage) { | 288 readyPort.handler = (readyMessage) { |
| 290 readyPort.close(); | 289 readyPort.close(); |
| 291 assert(readyMessage is List); | 290 assert(readyMessage is List); |
| 292 assert(readyMessage.length == 2); | 291 assert(readyMessage.length == 2); |
| 293 SendPort controlPort = readyMessage[0]; | 292 SendPort controlPort = readyMessage[0]; |
| 294 List capabilities = readyMessage[1]; | 293 List capabilities = readyMessage[1]; |
| 295 completer.complete(new Isolate(controlPort, | 294 completer.complete(new Isolate(controlPort, |
| 296 pauseCapability: capabilities[0], | 295 pauseCapability: capabilities[0], |
| 297 terminateCapability: capabilities[1])); | 296 terminateCapability: capabilities[1])); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 310 // These values need to be kept in sync with the class IsolateMessageHandler | 309 // These values need to be kept in sync with the class IsolateMessageHandler |
| 311 // in vm/isolate.cc. | 310 // in vm/isolate.cc. |
| 312 static const _PAUSE = 1; | 311 static const _PAUSE = 1; |
| 313 static const _RESUME = 2; | 312 static const _RESUME = 2; |
| 314 | 313 |
| 315 static SendPort _spawnFunction(SendPort readyPort, Function topLevelFunction, | 314 static SendPort _spawnFunction(SendPort readyPort, Function topLevelFunction, |
| 316 var message) | 315 var message) |
| 317 native "Isolate_spawnFunction"; | 316 native "Isolate_spawnFunction"; |
| 318 | 317 |
| 319 static SendPort _spawnUri(SendPort readyPort, String uri, | 318 static SendPort _spawnUri(SendPort readyPort, String uri, |
| 320 List<String> args, var message, | 319 List<String> args, var message) |
| 321 String packageRoot) | |
| 322 native "Isolate_spawnUri"; | 320 native "Isolate_spawnUri"; |
| 323 | 321 |
| 324 static void _sendOOB(port, msg) native "Isolate_sendOOB"; | 322 static void _sendOOB(port, msg) native "Isolate_sendOOB"; |
| 325 | 323 |
| 326 /* patch */ void _pause(Capability resumeCapability) { | 324 /* patch */ void _pause(Capability resumeCapability) { |
| 327 var msg = new List(4) | 325 var msg = new List(4) |
| 328 ..[0] = 0 // Make room for OOM message type. | 326 ..[0] = 0 // Make room for OOM message type. |
| 329 ..[1] = _PAUSE | 327 ..[1] = _PAUSE |
| 330 ..[2] = pauseCapability | 328 ..[2] = pauseCapability |
| 331 ..[3] = resumeCapability; | 329 ..[3] = resumeCapability; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 362 } | 360 } |
| 363 | 361 |
| 364 /* patch */ void addErrorListener(SendPort port) { | 362 /* patch */ void addErrorListener(SendPort port) { |
| 365 throw new UnsupportedError("addErrorListener"); | 363 throw new UnsupportedError("addErrorListener"); |
| 366 } | 364 } |
| 367 | 365 |
| 368 /* patch */ void removeErrorListener(SendPort port) { | 366 /* patch */ void removeErrorListener(SendPort port) { |
| 369 throw new UnsupportedError("removeErrorListener"); | 367 throw new UnsupportedError("removeErrorListener"); |
| 370 } | 368 } |
| 371 } | 369 } |
| OLD | NEW |