Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you’re poking around WASM consider falling down the Component Model rabbit hole:

https://github.com/WebAssembly/component-model/blob/main/des...

Threading is actively being worked on right now (to be released in 0.3.x, soon), and some changes just made their way into LLVM as well:

https://github.com/llvm/llvm-project/pull/175800



Iirc the async stuff in the component model isn’t actual threads but rather green threads, but correct me if I’m wrong


That’s right — I’m assuming you mean OS threads when you write “actual threads”.

Stackless Coroutines are currently supported for p3, stackful coroutines AKA “virtual threads” are coming (which I assume is what you mean by green threads), and “actual threads” as in OS threads are not currently a goal for the ABI AFAIK —- would you mind explaining some uses you were thinking of?


So if you are writing a WASM component model, and you were hoping to use Web Workers/SharedArrayBuffer, how would that work?

Do the virtual threads map on top of the Web Workers? Or are the Web Workers themselves green threads?

I was assuming Web Workers are OS threads


That’s a great question and something we’re going to have to figure out going forward on the JS side.

What I can say now is that the first version will probably be single threaded stack switching coroutines, and the model that seems to fit most naturally in my head is virtual threads mapping to some worker thread n in a premade pool.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: