| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // `paused` isn't handled yet. | 231 // `paused` isn't handled yet. |
| 232 try { | 232 try { |
| 233 // The VM will invoke [_startIsolate] with entryPoint as argument. | 233 // The VM will invoke [_startIsolate] with entryPoint as argument. |
| 234 SendPort controlPort = _spawnFunction(entryPoint); | 234 SendPort controlPort = _spawnFunction(entryPoint); |
| 235 RawReceivePort readyPort = new RawReceivePort(); | 235 RawReceivePort readyPort = new RawReceivePort(); |
| 236 controlPort.send([readyPort.sendPort, message]); | 236 controlPort.send([readyPort.sendPort, message]); |
| 237 Completer completer = new Completer<Isolate>.sync(); | 237 Completer completer = new Completer<Isolate>.sync(); |
| 238 readyPort.handler = (readyMessage) { | 238 readyPort.handler = (readyMessage) { |
| 239 assert(readyMessage == 'started'); | 239 assert(readyMessage == 'started'); |
| 240 readyPort.close(); | 240 readyPort.close(); |
| 241 completer.complete(new Isolate._fromControlPort(controlPort)); | 241 completer.complete(new Isolate(controlPort)); |
| 242 }; | 242 }; |
| 243 return completer.future; | 243 return completer.future; |
| 244 } catch (e, st) { | 244 } catch (e, st) { |
| 245 return new Future<Isolate>.error(e, st); | 245 return new Future<Isolate>.error(e, st); |
| 246 }; | 246 }; |
| 247 } | 247 } |
| 248 | 248 |
| 249 /* patch */ static Future<Isolate> spawnUri( | 249 /* patch */ static Future<Isolate> spawnUri( |
| 250 Uri uri, List<String> args, var message, { bool paused: false }) { | 250 Uri uri, List<String> args, var message, { bool paused: false }) { |
| 251 // `paused` isn't handled yet. | 251 // `paused` isn't handled yet. |
| 252 try { | 252 try { |
| 253 // The VM will invoke [_startIsolate] and not `main`. | 253 // The VM will invoke [_startIsolate] and not `main`. |
| 254 SendPort controlPort = _spawnUri(uri.toString()); | 254 SendPort controlPort = _spawnUri(uri.toString()); |
| 255 RawReceivePort readyPort = new RawReceivePort(); | 255 RawReceivePort readyPort = new RawReceivePort(); |
| 256 controlPort.send([readyPort.sendPort, args, message]); | 256 controlPort.send([readyPort.sendPort, args, message]); |
| 257 Completer completer = new Completer<Isolate>.sync(); | 257 Completer completer = new Completer<Isolate>.sync(); |
| 258 readyPort.handler = (readyMessage) { | 258 readyPort.handler = (readyMessage) { |
| 259 assert(readyMessage == 'started'); | 259 assert(readyMessage == 'started'); |
| 260 readyPort.close(); | 260 readyPort.close(); |
| 261 completer.complete(new Isolate._fromControlPort(controlPort)); | 261 completer.complete(new Isolate(controlPort)); |
| 262 }; | 262 }; |
| 263 return completer.future; | 263 return completer.future; |
| 264 } catch (e, st) { | 264 } catch (e, st) { |
| 265 return new Future<Isolate>.error(e, st); | 265 return new Future<Isolate>.error(e, st); |
| 266 }; | 266 }; |
| 267 return completer.future; | 267 return completer.future; |
| 268 } | 268 } |
| 269 | 269 |
| 270 static final RawReceivePort _self = _mainPort; | 270 static final RawReceivePort _self = _mainPort; |
| 271 static RawReceivePort get _mainPort native "Isolate_mainPort"; | 271 static RawReceivePort get _mainPort native "Isolate_mainPort"; |
| 272 | 272 |
| 273 static SendPort _spawnFunction(Function topLevelFunction) | 273 static SendPort _spawnFunction(Function topLevelFunction) |
| 274 native "Isolate_spawnFunction"; | 274 native "Isolate_spawnFunction"; |
| 275 | 275 |
| 276 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; | 276 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; |
| 277 } | 277 } |
| 278 | 278 |
| 279 patch class Capability { | 279 patch class Capability { |
| 280 /* patch */ factory Capability() { | 280 /* patch */ factory Capability() { |
| 281 throw new UnimplementedError(); | 281 throw new UnimplementedError(); |
| 282 } | 282 } |
| 283 } | 283 } |
| OLD | NEW |