mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
Implement new parameters on Isolate.spawn() for dart2js.
R=sgjesse@google.com Review URL: https://codereview.chromium.org//1294803003 .
This commit is contained in:
parent
73a6229d7c
commit
f8f06d784a
|
@ -1069,6 +1069,7 @@ class IsolateNatives {
|
|||
} else {
|
||||
topLevel();
|
||||
}
|
||||
context._updateGlobalState();
|
||||
}
|
||||
|
||||
if (startPaused) {
|
||||
|
|
|
@ -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],
|
||||
// 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]));
|
||||
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);
|
||||
|
|
|
@ -9,11 +9,32 @@ import "dart:async";
|
|||
import "package:async_helper/async_helper.dart";
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Isolate exiting immediately.
|
||||
isomain(args) {}
|
||||
|
||||
// Isolate exiting after running microtasks.
|
||||
isomain2(args) {
|
||||
scheduleMicrotask((){});
|
||||
}
|
||||
|
||||
// Isolate exiting after running timers.
|
||||
isomain3(args) {
|
||||
new Timer(Duration.ZERO, (){});
|
||||
}
|
||||
|
||||
main(){
|
||||
asyncStart();
|
||||
|
||||
test(isomain);
|
||||
test(isomain2);
|
||||
test(isomain3);
|
||||
|
||||
asyncEnd();
|
||||
}
|
||||
|
||||
void test(mainFunction) {
|
||||
asyncStart();
|
||||
|
||||
RawReceivePort exitPort = new RawReceivePort();
|
||||
exitPort.handler = (message) {
|
||||
Expect.equals(null, message);
|
||||
|
@ -21,7 +42,7 @@ main(){
|
|||
asyncEnd();
|
||||
};
|
||||
|
||||
Isolate.spawn(isomain,
|
||||
Isolate.spawn(mainFunction,
|
||||
null,
|
||||
// Setup handler as part of spawn.
|
||||
errorsAreFatal: false,
|
||||
|
|
|
@ -55,9 +55,6 @@ message3_test/constMap: RuntimeError # Issue 21817
|
|||
message3_test/constInstance: RuntimeError # Issue 21817
|
||||
browser/issue_12474_test: CompileTimeError # Issue 22529
|
||||
enum_const_test/02: RuntimeError # Issue 21817
|
||||
error_exit_at_spawn_test: Fail # Issue 23876
|
||||
error_at_spawn_test: Fail # Issue 23876
|
||||
exit_at_spawn_test: Fail # Issue 23876
|
||||
|
||||
[ $compiler == dart2js && $runtime != d8 ]
|
||||
error_exit_at_spawn_test: Skip # Issue 23876
|
||||
|
|
Loading…
Reference in a new issue