Re:V8 adds support for top-level await
by random314 on Wednesday September 25, 2019 @04:36PM
(#21075099)
Mutex specifically refers to OS/processor level constructs that protect critical sections using algorithms such as the bakery algorithm or special CPU instructions. None of these are required to protect the critical section in the example above.
You can just use a busy flag. I am not familiar with JS, so this is approximate syntax.
You can just use a busy flag. I am not familiar with JS, so this is approximate syntax.
while (busy) { await busyIsFalse } busy = true
Critical Section
busy = false
notify busyIsFalse
Simple boolean flags will work