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

Compatibility with standard async #1

Open
Belkharym opened this issue Mar 15, 2021 · 1 comment
Open

Compatibility with standard async #1

Belkharym opened this issue Mar 15, 2021 · 1 comment

Comments

@Belkharym
Copy link

Belkharym commented Mar 15, 2021

Can this be used as a general executor for futures? Or maybe to make rayon work on different workers?
I have been trying to find a way to make my program work on wasm, but since it has heavy computations, it take a very long time to process without multi-threading (There are some encryption decryption on very large files). So I made my program using the asynchronous paradigm of rust to pipeline my process, and a little bit of parallel processing with rayon (both of which work very well when compiled on windows). But when I compile it for Wasm, I rayon isn't able to launch its executor threads. So I was wondering if there was a way to make this executor work with rayon, or if I would have to re implement the functionality I need from rayon myself using this.

@Belkharym Belkharym changed the title Usage with Futures Compatibility with standard async Mar 15, 2021
@j-devel
Copy link
Contributor

j-devel commented Mar 16, 2021

Can this be used as a general executor for futures?

Yes, based on wasm_mt::Thread, you can implement custom executors for Rust futures (such as the toy executors in README and more practical wasm-mt-pool) in a fairly general manner (in my opinion). But, please note that, for any Rust futures involved here, their actual entity is a JavaScript Promise whose conversion is facilitated by wasm-bindgen.

After seeing this example in wasm-bindgen, I guess it's also possible to adapt wasm-mt-pool to being used with rayon.

So I was wondering if there was a way to make this executor work with rayon, or if I would have to re implement the functionality I need from rayon myself using this.

I would suggest, maybe, you put aside the (possibly laborious) rayon adaptation for the moment. Instead, as a first step, just try executing your parallel tasks with wasm-mt-pool to see if it works as you expect.

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