assemblyscript
assemblyscript copied to clipboard
AssemblyScript in Web Workers?
Sorry if this is not the proper place to ask.
Assuming a relatively complex computation that may take seconds/minutes to complete, how could an AssemblyScript running in a web worker send updates to the main thread?
In Javascript, this is simply a matter of using postMessage()
. How would AssemblyScript use postMessage()?
WebAssembly doesn't provide any job with workers. It only specifies some atomic operations and allow read / write for shared memory. Also note, AssemblyScript doesn't have thread safety yet for working with SharedArrayBuffer. But you still can work in old fashion with message passing between web workers which load individual wasm instances and syn all job on JS side. See example: https://blog.feather.systems/mandelbrot.html
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!