-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-isolatetriagedIssue has been triaged by sub teamIssue has been triaged by sub teamtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
From Dart SDK Docs:
The response object must follow the same restrictions as enforced by
SendPort.send
. It is recommended to only use simple values that can be sent to all isolates, like null, booleans, numbers or strings.
Dart SDK version: 2.19.0-444.3.beta (beta) (Wed Jan 4 15:18:31 2023 +0000) on "windows_x64"
import 'dart:isolate';
void app(SendPort sendPort) {
sendPort.send(Message.ok);
}
Future<void> main() async {
var receivePort = ReceivePort();
var sendPort = receivePort.sendPort;
var isolate = await Isolate.spawn<SendPort>(app, sendPort, paused: true);
isolate.addOnExitListener(sendPort, response: Message.done);
void onMessage(Object? message) {
switch (message) {
case Message.ok:
print('ok');
break;
case Message.done:
print('done');
receivePort.close();
break;
default:
throw UnsupportedError('$message');
}
}
receivePort.listen(onMessage);
isolate.resume(isolate.pauseCapability!);
}
enum Message {
ok,
done,
}
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-isolatetriagedIssue has been triaged by sub teamIssue has been triaged by sub teamtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)