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

Unified Diff: runtime/lib/isolate_patch.dart

Issue 297413002: Ensure that failure to start an isolate all end up in the future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make test file be named *_test.dart Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/isolate.cc » ('j') | tests/isolate/isolate_create_error_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate_patch.dart
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index add3c5143f117c404d8a693aec1abd308b6522f7..d501ce1b07baa9f370b5c90d68970dba3edd091a 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -200,24 +200,36 @@ void _startIsolate(Function entryPoint, bool isSpawnUri) {
keepAlivePort.close();
SendPort replyTo = message[0];
- if (replyTo != null) {
- // TODO(floitsch): don't send ok-message if we can't find the entry point.
- replyTo.send("started");
- }
if (isSpawnUri) {
assert(message.length == 3);
List<String> args = message[1];
var isolateMessage = message[2];
- if (entryPoint is _MainFunctionArgsMessage) {
+ if (entryPoint == null) {
+ // Set to null when lookup of "main" failed in C++ code.
+ if (replyTo != null) {
+ replyTo.send(["error",
+ "No main method in isolate library"]);
+ }
+ } else if (entryPoint is _MainFunctionArgsMessage) {
+ if (replyTo != null) replyTo.send("started");
entryPoint(args, isolateMessage);
} else if (entryPoint is _MainFunctionArgs) {
+ if (replyTo != null) replyTo.send("started");
entryPoint(args);
- } else {
+ } else if (entryPoint is _MainFunction) {
+ if (replyTo != null) replyTo.send("started");
entryPoint();
+ } else {
+ // Report error back to spawner.
+ if (replyTo != null) {
+ replyTo.send(["error",
+ "Incorrect parameter count on main: $entryPoint"]);
+ }
}
} else {
assert(message.length == 2);
var entryMessage = message[1];
+ if (replyTo != null) replyTo.send("started");
entryPoint(entryMessage);
}
}
@@ -256,9 +268,15 @@ patch class Isolate {
controlPort.send([readyPort.sendPort, args, message]);
Completer completer = new Completer<Isolate>.sync();
readyPort.handler = (readyMessage) {
- assert(readyMessage == 'started');
readyPort.close();
- completer.complete(new Isolate(controlPort));
+ if ('started' == readyMessage) {
+ completer.complete(new Isolate(controlPort));
+ } else {
+ assert(readyMessage is List && readyMessage[0] == "error");
+ String error = readyMessage[1];
+ var remoteError = new IsolateSpawnException(error);
+ completer.completeError(remoteError);
+ }
};
return completer.future;
} catch (e, st) {
« no previous file with comments | « no previous file | runtime/vm/isolate.cc » ('j') | tests/isolate/isolate_create_error_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698