Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 163523003: Add 'startPaused' option to Isolate.spawn*. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Actually add test. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 startPaused: false }) {
231 try { 231 try {
232 // The VM will invoke [_startIsolate] with entryPoint as argument. 232 // The VM will invoke [_startIsolate] with entryPoint as argument.
233 SendPort controlPort = _spawnFunction(entryPoint); 233 SendPort controlPort = _spawnFunction(entryPoint);
234 RawReceivePort readyPort = new RawReceivePort(); 234 RawReceivePort readyPort = new RawReceivePort();
235 controlPort.send([readyPort.sendPort, message]); 235 controlPort.send([readyPort.sendPort, message]);
236 Completer completer = new Completer<Isolate>.sync(); 236 Completer completer = new Completer<Isolate>.sync();
237 readyPort.handler = (readyMessage) { 237 readyPort.handler = (readyMessage) {
238 assert(readyMessage == 'started'); 238 assert(readyMessage == 'started');
239 readyPort.close(); 239 readyPort.close();
240 completer.complete(new Isolate._fromControlPort(controlPort)); 240 completer.complete(new Isolate._fromControlPort(controlPort));
241 }; 241 };
242 return completer.future; 242 return completer.future;
243 } catch (e, st) { 243 } catch (e, st) {
244 return new Future<Isolate>.error(e, st); 244 return new Future<Isolate>.error(e, st);
245 }; 245 };
246 } 246 }
247 247
248 /* patch */ static Future<Isolate> spawnUri( 248 /* patch */ static Future<Isolate> spawnUri(
249 Uri uri, List<String> args, var message) { 249 Uri uri, List<String> args, var message, { bool startPaused: false }) {
250 try { 250 try {
251 // The VM will invoke [_startIsolate] and not `main`. 251 // The VM will invoke [_startIsolate] and not `main`.
252 SendPort controlPort = _spawnUri(uri.toString()); 252 SendPort controlPort = _spawnUri(uri.toString());
253 RawReceivePort readyPort = new RawReceivePort(); 253 RawReceivePort readyPort = new RawReceivePort();
254 controlPort.send([readyPort.sendPort, args, message]); 254 controlPort.send([readyPort.sendPort, args, message]);
255 Completer completer = new Completer<Isolate>.sync(); 255 Completer completer = new Completer<Isolate>.sync();
256 readyPort.handler = (readyMessage) { 256 readyPort.handler = (readyMessage) {
257 assert(readyMessage == 'started'); 257 assert(readyMessage == 'started');
258 readyPort.close(); 258 readyPort.close();
259 completer.complete(new Isolate._fromControlPort(controlPort)); 259 completer.complete(new Isolate._fromControlPort(controlPort));
(...skipping 12 matching lines...) Expand all
272 native "Isolate_spawnFunction"; 272 native "Isolate_spawnFunction";
273 273
274 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; 274 static SendPort _spawnUri(String uri) native "Isolate_spawnUri";
275 } 275 }
276 276
277 patch class Capability { 277 patch class Capability {
278 /* patch */ factory Capability() { 278 /* patch */ factory Capability() {
279 throw new UnimplementedError(); 279 throw new UnimplementedError();
280 } 280 }
281 } 281 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/isolate_helper.dart » ('j') | sdk/lib/_internal/lib/isolate_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698