4 ms·
Does the SharedArrayBuffer approach offer any way to tell the OS scheduler to wait? Because the only waiting method I know of is busy waiting, aka wasting cycle
by est31 5y ago
Does the SharedArrayBuffer approach offer any way to tell the OS scheduler to wait? Because the only waiting method I know of is busy waiting, aka wasting cycles at 100% of a CPU core. In normal processes you can call a sleep function, which saves CPU cycles, but there is no synchronous method for that available in javascript.
- benno128 5y agoIt's part of the Atomics feature set (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...). You have a shared chunk of memory and you say "please sleep until this memory changes". Then it's up to the host to change that memory.
- est31 5y agoOh that's pretty neat, didn't know about that.