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

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

Issue 88783002: Isolate.spawn{Uri} only reports errors asynchronously. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload due to error 500. Created 7 years 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
« no previous file with comments | « no previous file | runtime/lib/print_patch.dart » ('j') | sdk/lib/_internal/pub/lib/src/dart.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // The VM will invoke [_startIsolate] with entryPoint as argument. 234 // The VM will invoke [_startIsolate] with entryPoint as argument.
235 SendPort controlPort = _spawnFunction(entryPoint); 235 SendPort controlPort = _spawnFunction(entryPoint);
236 RawReceivePort readyPort = new RawReceivePort(); 236 RawReceivePort readyPort = new RawReceivePort();
237 controlPort.send([readyPort.sendPort, message]); 237 controlPort.send([readyPort.sendPort, message]);
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._fromControlPort(controlPort));
242 }; 242 };
243 } catch(e, st) { 243 } catch(e, st) {
244 // TODO(14718): we want errors to go into the returned future. 244 // Don't complete immediately with an error, since the caller didn't
245 rethrow; 245 // yet have the opportunity to install an error handler.
246 scheduleMicrotask(() {
247 completer.completeError(e, st);
248 });
Lasse Reichstein Nielsen 2013/12/13 11:16:58 How about doing the same as in the JS patch: try
floitsch 2013/12/13 12:13:37 Done.
246 }; 249 };
247 return completer.future; 250 return completer.future;
248 } 251 }
249 252
250 /* patch */ static Future<Isolate> spawnUri( 253 /* patch */ static Future<Isolate> spawnUri(
251 Uri uri, List<String> args, var message) { 254 Uri uri, List<String> args, var message) {
252 Completer completer = new Completer<Isolate>.sync(); 255 Completer completer = new Completer<Isolate>.sync();
253 try { 256 try {
254 // The VM will invoke [_startIsolate] and not `main`. 257 // The VM will invoke [_startIsolate] and not `main`.
255 SendPort controlPort = _spawnUri(uri.toString()); 258 SendPort controlPort = _spawnUri(uri.toString());
256 RawReceivePort readyPort = new RawReceivePort(); 259 RawReceivePort readyPort = new RawReceivePort();
257 controlPort.send([readyPort.sendPort, args, message]); 260 controlPort.send([readyPort.sendPort, args, message]);
258 readyPort.handler = (readyMessage) { 261 readyPort.handler = (readyMessage) {
259 assert(readyMessage == 'started'); 262 assert(readyMessage == 'started');
260 readyPort.close(); 263 readyPort.close();
261 completer.complete(new Isolate._fromControlPort(controlPort)); 264 completer.complete(new Isolate._fromControlPort(controlPort));
262 }; 265 };
263 } catch(e, st) { 266 } catch(e, st) {
264 // TODO(14718): we want errors to go into the returned future. 267 // Don't complete immediately with an error, since the caller didn't
265 rethrow; 268 // yet have the opportunity to install an error handler.
269 scheduleMicrotask(() {
270 completer.completeError(e, st);
271 });
266 }; 272 };
267 return completer.future; 273 return completer.future;
268 } 274 }
269 275
270 static final RawReceivePort _self = _mainPort; 276 static final RawReceivePort _self = _mainPort;
271 static RawReceivePort get _mainPort native "Isolate_mainPort"; 277 static RawReceivePort get _mainPort native "Isolate_mainPort";
272 278
273 static SendPort _spawnFunction(Function topLevelFunction) 279 static SendPort _spawnFunction(Function topLevelFunction)
274 native "Isolate_spawnFunction"; 280 native "Isolate_spawnFunction";
275 281
276 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; 282 static SendPort _spawnUri(String uri) native "Isolate_spawnUri";
277 } 283 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/print_patch.dart » ('j') | sdk/lib/_internal/pub/lib/src/dart.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698