News for hackers. Stuff that matters.
Re:V8 adds support for top-level await by inglor on Wednesday September 25, 2019 @02:47AM (#21068349)
A promise is a lock in that resolving it is the 'release' and awaiting it is `acquire`.

For example:

``` let release; const acquire = new Promise(resolve => release = resolve);

(async () => {

  await acquire;
  // use here
  release(); // now others can use it
})(); ```

This is a bit different because multiple people can await the lock here so it's like a "one time multicast mutex" making it more akin to condition variables.

That said - thinking about it as a mutex is a really backwards way in my opinion.

There are no comments on this comment yet.