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

could this work with jco? #1

Open
DougAnderson444 opened this issue Mar 2, 2024 · 1 comment
Open

could this work with jco? #1

DougAnderson444 opened this issue Mar 2, 2024 · 1 comment

Comments

@DougAnderson444
Copy link

Joel @dicej,

I need async in order to access IndexedDB from WIT component written in Rust but using jco.

Do you think this approach could work with jco?
Any advice / thoughts on how that could look?

Thought I'd ask before attempting to dive in... I'm not really patient enough to wait for Preview 3 ;P

thanks!

@dicej
Copy link
Owner

dicej commented Mar 2, 2024

Hi @DougAnderson444. To be clear: async works great in WASI 0.2.0 for components which are not composed with other components, and it also works great for composed components where only one of the subcomponents needs to do I/O at a time. If either of those apply to your use case, then isyswasfa is overkill. For reference, here's an example of a Rust component that uses a simple wasi:io/poll-based executor to do async I/O in a reasonably idiomatic way without any special host features: https://github.com/bytecodealliance/wasmtime/blob/main/crates/test-programs/src/bin/api_proxy_streaming.rs. See also https://blog.yoshuawuyts.com/building-an-async-runtime-for-wasi/ for an example of a more general-purpose executor based on WASI 0.2.0.

That said, if you really do need to compose components which do concurrent I/O, then porting isyswasfa to jco might make sense. I don't have experience with jco, nor do I have time to work on such a port, but if you're motivated you could look at the changes I made to wasmtime-wit-bindgen (in the wasmtime submodule in this repo), port them to jco, and then port https://github.com/dicej/isyswasfa/blob/main/host/src/lib.rs to jco as well. I'll confess I haven't made any effort to document that code, and chunks of it are completely untested -- it's all very much prototype-quality at this point and isn't necessarily designed for production use. Happy to answer any questions about it, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants