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

Transferring transferables to the new thread #8

Open
felipellrocha opened this issue Jun 17, 2022 · 2 comments
Open

Transferring transferables to the new thread #8

felipellrocha opened this issue Jun 17, 2022 · 2 comments

Comments

@felipellrocha
Copy link

I haven't been able to find a path that would allow me to do that

@DouglasDwyer
Copy link
Contributor

Because the worker messaging API is utilized for thread initialization and termination, there isn't currently a way to send transferables to another thread. The wasm_thread crate would need to be modified to allow for user-generated messages to be posted across worker boundaries, and also allow for asynchronous entrypoints as mentioned in #6. This is possible, but in my view, not necessarily in keeping with the goal of the crate (which is to be a drop-in replacement for std::thread); such functionality would require adding WASM-specific details to the abstraction. It's totally up to the crate owner, of course, but I think it would probably be worth creating a separate crate with webworker-specific functionality (like async entrypoints and the postMessage API) to allow for these advanced worker use cases.

@chemicstry
Copy link
Owner

Yes, implementing async entry points and message posting would deviate too far from std::thread API. If we were to implement such features, I think creating a separate crate is the best option. Most of the resuable code could be moved out of this crate and it would instead serve as an API bridge between std::thread and the new webworker-specific crate.

Unfortunatelly, I'm not currently working with wasm so I don't have any interest in implementing this, but I would be happy to accept PRs, help coordinate the effort, or just grant maintainer rights.

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

3 participants