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

I just found out you can sync sleep in JavaScript. I’m using it to implement multi-process sync file locks that need to interoperate with a large non-async framework (eslint).

    Atomics.wait(this.sleepBuffer, 0, 0, ms)


What the fuck?

>Thrown in one of the following cases:

>If the current thread cannot be blocked (for example, because it's the main thread).

I guess that's why it's not so widely used


It's not permitted on the browser main thread, but works fine on the Node main thread.




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

Search: