-
Notifications
You must be signed in to change notification settings - Fork 294
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
Can't send dart version of rust object in SendPort #2321
Comments
Hi! Thanks for opening your first issue here! 😄 |
Hmm, I guess it is because it contains some pointer etc. And I wonder whether sending it to another isolate will cause the dispose/GC logic to somehow change (possibly it's OK but not tested). One way is to PR to allow such usage. Another workaround may be, put your Rust objects at Rust side (say, a HashMap), and only pass around an integer index here and there. Btw, what is your real scenario that requires sending across isolates? Maybe by discussing that we can find a way to avoid using isolates or avoid using this proposed feature. |
I think you may be right about this. I have rust code that is fetching some data from a web API, then doing some slightly heavy processing (doing a few regex searches against several thousand pieces of text). My thought was to put the computational work on another isolate (which is what I would do if it were pure Dart), but after posting this issue, I found the Asynchronous Dart page in the docs. Is that page saying that the rust code will automatically be running in a thread that is not the same one running the main isolate? If so, then it sounds like I don't actually need the extra isolate after all, and I could just count on the rust computations running on a separate thread. |
Yes. If your Rust code do heavy processing, it will not block your Dart code. For example, even if your rust code do a |
Thanks for the explanation! This should solve my problem |
You are welcome and happy to see it is solved! |
Describe the bug
Thanks for creating this great library!
I created a struct in Rust and generated the Dart version of it. I'm trying to send it through a SendPort, but I'm getting an error that seems to indicate that you can't send
RustArc
in a SendPort. Specifically the error is:I searched the documentation and github issues, but didn't find any related information. Is there a workaround for this?
Steps to reproduce
sendPort.send()
with the Dart version of the Rust struct.Logs
I don't think this is a generation issue, but I can add logs if needed.
Expected behavior
No response
Generated binding code
No response
OS
Linux
Version of
flutter_rust_bridge_codegen
2.3.0
Flutter info
No response
Version of
clang++
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: