linrongbin16 opened issue #8128:
hi,
how does wasm threading/eventloop works with rust?
because node.js/deno these javascript runtime usually have their own eventloop, which handles the async/await and IO/network.
but when I am trying to embed wasm into rust, I want to use wasm as a scripting language interpreter, for example I am compiling javascript, and I want to interpret it in rust, with the help of wasm.
And the eventloop (or main thread) should be handled by rust, what will happen if I run async/await in javascript?
alexcrichton commented on issue #8128:
Hello! I fear that there's no easy answer to your question here since there's a lot of variables that could be involved. The closest thing to an easy answer is probably "tokio". Many programs using async in Rust use tokio as their event loop, and you can use Wasmtime on top of that tokio event loop.
As for how an in-guest interpreter would integrate with the Wasmtime event loop, that I fear also does not have a great answer. At this time the recommendation for that looks something along the lines of:
- The host uses async wasmtime meaning that when the guest "blocks" it yields to the host (doesn't block the host)
- The guest blocks and performs its own event loop as necessary
That ends up having an event loop on an event loop which works because blocking in the guest doesn't block the host. There's work to help remove the event loop from the guest, but that's still under development.
That's at least some information, but I'm not sure if tha answers your questions?
linrongbin16 closed issue #8128:
hi,
how does wasm threading/eventloop works with rust?
because node.js/deno these javascript runtime usually have their own eventloop, which handles the async/await and IO/network.
but when I am trying to embed wasm into rust, I want to use wasm as a scripting language interpreter, for example I am compiling javascript, and I want to interpret it in rust, with the help of wasm.
And the eventloop (or main thread) should be handled by rust, what will happen if I run async/await in javascript?
linrongbin16 commented on issue #8128:
that's exactly what I am looking for!
With I study for more time and have a better knowledge, I will keep solving new issues if I have.
thanks!
Last updated: Nov 22 2024 at 16:03 UTC