site-www
site-www copied to clipboard
[2.19] `Isolate.run()` docs
https://dart-review.googlesource.com/c/sdk/+/217008
Summary
"Runs [computation] in a new isolate and returns the result." - API docs
Currently, you have to use sendport and receiveport to get a return from an isolate. Isolate.run() doesn't eliminate the need for send-and-receive ports (there are still cases where one might want to fine tune the configuration of using send-and-receive ports for some reason, and they still can), it just wraps their usage so users don't have to handroll that implementation themselves. Now you can just call isolate.run() and get a return without having to write anything else
Evaluation
- Potential updates needed on Concurrency in Dart
- The use of sendport/receiveport shouldn't be mentioned in the default examples.
- Use isolate.run by default, mention that you could use send/receive if for some reason you want to configure that more closely
- This page might not be the place to go into that much detail
- Potential new content needed; needs more info to determine
- I don't think there is a need for new content, just updating the existing mentions of isolate that go in detail enough to talk about sharing data between isolates.
- Not sure about the significance of the flutter samples repo, but it might need updating or adding to
- Use of send and receive ports is the default
- My suggestion: any use of send and receive ports needs to be changed to isolate.run
- Then, maybe, create a new example that shows how to use send and receive if you really want to
Looks like this may be removed temporarily: https://dart-review.googlesource.com/c/sdk/+/237940
Will mark as blocked for now and keep tabs on the feature.
This has been reverted in https://github.com/dart-lang/sdk/commit/d063ac32335881e34f324746b8e155cc93bc57d8, so changing the milestone.
This is is in the change log for 2.19 now, and seems to be implemented at this point (I could be misreading that though), so I'm going to treat it as such and convert this into an evaluation issue.
Tracking Flutter impact (will determine if it's included in 2.19(?))
https://github.com/dart-lang/sdk/issues/48566
Note: this example shouldn't change because there is no method to accomplish this with run()
yet
Fixing PRs merged into v2.19