Index: sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
diff --git a/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart b/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
index 53361cc3a48df3d41deaf033e42281062e40c66d..eb681071b2adf16a393523cc2a7fe1012b7a6bc2 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
@@ -25,11 +25,35 @@ class Isolate { |
static Future<Isolate> spawn(void entryPoint(message), var message, |
{bool paused: false, bool errorsAreFatal, |
SendPort onExit, SendPort onError}) { |
+ bool forcePause = (errorsAreFatal != null) || |
+ (onExit != null) || |
+ (onError != null); |
try { |
- return IsolateNatives.spawnFunction(entryPoint, message, paused) |
- .then((msg) => new Isolate(msg[1], |
- pauseCapability: msg[2], |
- terminateCapability: msg[3])); |
+ // TODO: Consider passing the errorsAreFatal/onExit/onError values |
+ // as arguments to the internal spawnUri instead of setting |
+ // them after the isolate has been created. |
+ return IsolateNatives.spawnFunction(entryPoint, message, |
+ paused || forcePause) |
+ .then((msg) { |
+ var isolate = new Isolate(msg[1], |
+ pauseCapability: msg[2], |
+ terminateCapability: msg[3]); |
+ if (forcePause) { |
+ if (errorsAreFatal != null) { |
+ isolate.setErrorsFatal(errorsAreFatal); |
+ } |
+ if (onExit != null) { |
+ isolate.addOnExitListener(onExit); |
+ } |
+ if (onError != null) { |
+ isolate.addErrorListener(onError); |
+ } |
+ if (!paused) { |
+ isolate.resume(isolate.pauseCapability); |
+ } |
+ } |
+ return isolate; |
+ }); |
} catch (e, st) { |
return new Future<Isolate>.error(e, st); |
} |
@@ -70,7 +94,7 @@ class Isolate { |
isolate.addOnExitListener(onExit); |
} |
if (onError != null) { |
- isolate.addOnErrorListener(onError); |
+ isolate.addErrorListener(onError); |
} |
if (!paused) { |
isolate.resume(isolate.pauseCapability); |