| 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 patch class ReceivePort { | 5 patch class ReceivePort { |
| 6 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 6 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 7 | 7 |
| 8 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = | 8 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = |
| 9 _ReceivePortImpl.fromRawReceivePort; | 9 _ReceivePortImpl.fromRawReceivePort; |
| 10 } | 10 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // The VM will invoke [_startIsolate] with entryPoint as argument. | 209 // The VM will invoke [_startIsolate] with entryPoint as argument. |
| 210 SendPort controlPort = _spawnFunction(entryPoint); | 210 SendPort controlPort = _spawnFunction(entryPoint); |
| 211 RawReceivePort readyPort = new RawReceivePort(); | 211 RawReceivePort readyPort = new RawReceivePort(); |
| 212 controlPort.send([readyPort.sendPort, message]); | 212 controlPort.send([readyPort.sendPort, message]); |
| 213 readyPort.handler = (readyMessage) { | 213 readyPort.handler = (readyMessage) { |
| 214 assert(readyMessage == 'started'); | 214 assert(readyMessage == 'started'); |
| 215 readyPort.close(); | 215 readyPort.close(); |
| 216 completer.complete(new Isolate._fromControlPort(controlPort)); | 216 completer.complete(new Isolate._fromControlPort(controlPort)); |
| 217 }; | 217 }; |
| 218 } catch(e, st) { | 218 } catch(e, st) { |
| 219 // TODO(floitsch): we want errors to go into the returned future. | 219 // TODO(14718): we want errors to go into the returned future. |
| 220 rethrow; | 220 rethrow; |
| 221 }; | 221 }; |
| 222 return completer.future; | 222 return completer.future; |
| 223 } | 223 } |
| 224 | 224 |
| 225 /* patch */ static Future<Isolate> spawnUri( | 225 /* patch */ static Future<Isolate> spawnUri( |
| 226 Uri uri, List<String> args, var message) { | 226 Uri uri, List<String> args, var message) { |
| 227 Completer completer = new Completer<Isolate>.sync(); | 227 Completer completer = new Completer<Isolate>.sync(); |
| 228 try { | 228 try { |
| 229 // The VM will invoke [_startIsolate] and not `main`. | 229 // The VM will invoke [_startIsolate] and not `main`. |
| 230 SendPort controlPort = _spawnUri(uri.toString()); | 230 SendPort controlPort = _spawnUri(uri.toString()); |
| 231 RawReceivePort readyPort = new RawReceivePort(); | 231 RawReceivePort readyPort = new RawReceivePort(); |
| 232 controlPort.send([readyPort.sendPort, args, message]); | 232 controlPort.send([readyPort.sendPort, args, message]); |
| 233 readyPort.handler = (readyMessage) { | 233 readyPort.handler = (readyMessage) { |
| 234 assert(readyMessage == 'started'); | 234 assert(readyMessage == 'started'); |
| 235 readyPort.close(); | 235 readyPort.close(); |
| 236 completer.complete(new Isolate._fromControlPort(controlPort)); | 236 completer.complete(new Isolate._fromControlPort(controlPort)); |
| 237 }; | 237 }; |
| 238 } catch(e, st) { | 238 } catch(e, st) { |
| 239 // TODO(floitsch): we want errors to go into the returned future. | 239 // TODO(14718): we want errors to go into the returned future. |
| 240 rethrow; | 240 rethrow; |
| 241 }; | 241 }; |
| 242 return completer.future; | 242 return completer.future; |
| 243 } | 243 } |
| 244 | 244 |
| 245 static final RawReceivePort _self = _mainPort; | 245 static final RawReceivePort _self = _mainPort; |
| 246 static RawReceivePort get _mainPort native "Isolate_mainPort"; | 246 static RawReceivePort get _mainPort native "Isolate_mainPort"; |
| 247 | 247 |
| 248 static SendPort _spawnFunction(Function topLevelFunction) | 248 static SendPort _spawnFunction(Function topLevelFunction) |
| 249 native "Isolate_spawnFunction"; | 249 native "Isolate_spawnFunction"; |
| 250 | 250 |
| 251 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; | 251 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; |
| 252 } | 252 } |
| OLD | NEW |