assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

AssemblyScript in Web Workers?

Open armandn opened this issue 1 year ago • 1 comments

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()?

armandn avatar Aug 02 '22 09:08 armandn

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

MaxGraey avatar Aug 02 '22 11:08 MaxGraey

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!

github-actions[bot] avatar Sep 01 '22 23:09 github-actions[bot]