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