Skip to content

arifd/minimal-multithreaded-wasm-in-the-browser-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Multithreaded WASM Example

This example shows how to use rayon and wasm_bindgen together which in the current implementation will exploit JS worker threads to be able to compute concurrently.

For some reason I can only get this to work in Chrome, wheras on FireFox it displays any combination of hanging or displaying this error: SyntaxError: export declarations may only appear at top level of a module for every thread on your computer.

...Despite the fact that the two examples I used to get this to work both work in FF and Chrome!

I'll need to investigate further!

To run, you need wasm-pack on your system: https://rustwasm.github.io/wasm-pack/installer/

Then build with: wasm-pack build --target web serve with: python3 serve.py then go to: http://127.0.0.1:8000/index.html in your browser.