remko / waforth

Small but complete dynamic Forth Interpreter/Compiler for and in WebAssembly
https://mko.re/waforth
MIT License
491 stars 27 forks source link

Investigate blocking design using threads #43

Closed remko closed 2 years ago

remko commented 2 years ago

Because WebAssembly cannot block on e.g. I/O when used from JavaScript, the design is more complicated:

Can we use thread support to make the WebAssembly wait on input, and this way make the design simpler?

Alternative is to use Atomics.wait (currently not supported on Android), since the blocking thing is purely a JavaScript/browser problem, and should probably be handled there.

Running from a different thread may also make it possible to provide a live debug view of the stack while stepping through code. Not sure if there are performance implications for running from a different thread, and accessing the shared memory.

remko commented 2 years ago

Closing this issue for now, because it's not something I probably will look into soon. It might be useful to do blocking i/o, but it doesn't seem usable for making everything blocking (e.g. fetching URLs), because of the limited primitives for data sharing in JavaScript. I might reopen this later.