Wasm-bindgen: Create a simple multithreading example

Created on 23 Jul 2019  路  4Comments  路  Source: rustwasm/wasm-bindgen

Motivation

The ray-tracing example is a good showcase for what can be done with multithreading, but is a bit hard to grok, especially if you're interested in the fundamentals. The raytracing example uses Rayon, has an entire pool implementation, spawns multiple workers, etc.

Proposed Solution

A new, minimal and boring example of multithreading which spawns a single worker.

Alternatives

None that I can think of!

enhancement

Most helpful comment

For me, a good example would highlight exactly what rough edges and gotchas exist even for a minimal use-case. Something purely illustrative, like executing a loop with enough iterations that it would freeze up a UI thread for a few seconds, after which it writes some value that can be accessed by the UI thread.

All 4 comments

There's a much longer explainer post about the internals of what's going on which is still largely accurate today, but for a smaller example it's probably not a bad idea as well! It's unfortunately all still a bit rough around the edges with all the gotchas to get it up and running from scratch, but do you have an idea of what a small example you'd like to see is?

For me, a good example would highlight exactly what rough edges and gotchas exist even for a minimal use-case. Something purely illustrative, like executing a loop with enough iterations that it would freeze up a UI thread for a few seconds, after which it writes some value that can be accessed by the UI thread.

Yes, this would be fantastic if possible.

Seconded. Computing a layout iterativly off-mainthread and updating the screen with the result in every callback to request_animation_frame is also my main use case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NateLing picture NateLing  路  3Comments

bantic picture bantic  路  4Comments

MarcAntoine-Arnaud picture MarcAntoine-Arnaud  路  3Comments

kurbaniec picture kurbaniec  路  3Comments

derekdreery picture derekdreery  路  3Comments