4 ms·
I find it really crazy how far this had to go to support something as simple as sleep. I became aware of this problem when I started writing WASI last year. So
by richardanaya 5y ago
I find it really crazy how far this had to go to support something as simple as sleep. I became aware of this problem when I started writing WASI last year. So so much unix code is based on the idea of synchronous operations. My conclusions were that some sort of ability to have atomics that could pause a web assembly running on a web worker while an async operation completed then unlocked the blocked web assembly was the only way this could be sanely done.
- lucideer 5y ago> something as simple as sleep Is sleep really considered simple?
- 3v1n0 5y agoC io APIs are sync, but there are so many that are not such thing. Potentially would even be possible to expose something like the io_uring async api to the browsers I guess.
- yxhuvud 5y agoWhile io_uring certainly is great, but it is a: Linux only. The main interest of browsers are Windows and Mac as most users are on those platforms. b: Limited to modern variants of the kernel - this is a greater problem the more features that is needed. Not everyone wants to be or can be a kernel hipster.
- flohofwoe 5y agoTo be fair, UI applications on most platforms that are not Windows or Linux have a very similar problem, you can't simply block the event loop for a few seconds or the whole UI will freeze and the OS will most likely terminate the application (on mobile at last). Usually one can workaround this with threads, alas, threading in the browser environment opens up a whole new can of worms. Asynchronous programming is a different coding mindset, and async-await provides a convenient hack/workaround/solution to go back to a simple linear execution flow (even if that's just an "illusion"). But this problem had been solved many decades ago on the OS level in UNIX and other multitasking operating systems already (and solved it much better, because async-await is essentially cooperative multitasking, like in Windows 3.x or classic MacOS).