Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand isolate documentation to include FFI usage #6235

Open
ericwindmill opened this issue Nov 25, 2024 · 1 comment
Open

Expand isolate documentation to include FFI usage #6235

ericwindmill opened this issue Nov 25, 2024 · 1 comment
Labels
co.request Community ask for documentation dev.concurrency Relates to concurrency dev.interop Relates to use of native code as part of your Dart app e3-weeks Complete in < 4 weeks of normal, not dedicated, work p2-medium Necessary but not urgent concern. Resolve when possible.

Comments

@ericwindmill
Copy link
Contributor

ericwindmill commented Nov 25, 2024

What information needs to be added?

There's a gap in the docs when it comes to using isolates and FFI. This ticket is related to #4571

This ticket was motivated by this conversation on the community forum. In this conversation, @filiph explained the issue succinctly:

It doesn’t matter if the other language is C++, C, Rust or whatever else. The point is that you have an external (non-Dart) library that you want to use throughout the execution of the app, and you need to communicate with this external library continuously (i.e. it’s not a single batch job).

Filip and others added a list of problems that they believe should be documented:

  • External (non-Dart) code doesn’t know about isolates, which makes managing callbacks from FFI-land to Dart really hard (this is a known issue but there are workarounds)
  • assuming we have the consumer (main) isolate, the worker isolate (with FFI code) and the external (C/C++/Rust) code, how should one send data in a way that minimizes copying? Assume there’s a non-trivial amount of data going in one or both directions every frame.
    • If the answer is to share data between Dart and external code, where should one allocate and who should own (and free) the memory?
  • more generally, how does one wire all this together? @mraleph’s code above is a great start but it took me quite a while to understand what’s going on with things like: await for (var v in stream(() async* { ... })) { ... } and, to be honest, I’m still having trouble grokking the whole thing.

Where should this new content appear?

A new page under /language/concurrency or a new page under /interopability.

@ericwindmill ericwindmill added co.request Community ask for documentation dev.interop Relates to use of native code as part of your Dart app dev.concurrency Relates to concurrency labels Nov 25, 2024
@ericwindmill
Copy link
Contributor Author

This is something I'm willing to work on, but it'll take some time and conversations with SWEs to figure out the best way to document this.

@parlough parlough added p2-medium Necessary but not urgent concern. Resolve when possible. e3-weeks Complete in < 4 weeks of normal, not dedicated, work labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co.request Community ask for documentation dev.concurrency Relates to concurrency dev.interop Relates to use of native code as part of your Dart app e3-weeks Complete in < 4 weeks of normal, not dedicated, work p2-medium Necessary but not urgent concern. Resolve when possible.
Projects
None yet
Development

No branches or pull requests

2 participants