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

Unified Diff: sdk/lib/_internal/js_runtime/lib/isolate_patch.dart

Issue 1294803003: Implement new parameters on Isolate.spawn() for dart2js. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Make tests succeed. Created 5 years, 4 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 | « sdk/lib/_internal/js_runtime/lib/isolate_helper.dart ('k') | tests/isolate/exit_at_spawn_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/isolate_helper.dart ('k') | tests/isolate/exit_at_spawn_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698