4 ms·
Having not seen the Web Locks proposal before, it feels like a mistake. The ease of using the API combined with the intricacies of locking feels like substantia
by lucasyvas 5y ago
Having not seen the Web Locks proposal before, it feels like a mistake. The ease of using the API combined with the intricacies of locking feels like substantial misuse is guaranteed (especially in a language dominated by learners).
We've only recently seen languages capable of being smarter about preventing concurrency issues at compile time, and JavaScript is not ready.
I suppose it could be nice to have, but I'm almost certain I'd be searching for ways to solve my problem in other ways before reaching for this.
Edit: The lock is acquired via a string as well - I'm sure that'll never collide in a third party library...
- mmastrac 5y agoCookies and localStorage are scoped by string and we've just learned to deal with it. Namespaces are hard and strings are probably one of the best of the bad solutions that don't massively increase complexity.
- wheybags 5y agoIt could just be an object that you create, and then .lock() on though. Like almost every other language...
- mmastrac 5y agoFair, but how does one claim the same object on two pages in a race-free manner? You could allow them to be smuggled through postMessage, but then two pages would have to coordinate creation/reception of the lock. I'd love to hear better solutions as I might be too tired pre-coffee to brainstorm something more elegant. I find it interesting that Windows effectively uses global string-named mutexes and overall still has a few very rare conflicts that usually make the news [1]. [1] https://geek-week.imtqy.com/articles/en488834/index.html https://geek-week.imtqy.com/articles/en488834/index.html
- pmarreck 5y agoisn't "leader election" a big part of RAFT consensus? So does this mean it's basically "partially-applied RAFT"? I could see that becoming a problem
- marwis 5y agoYeah, they should at least allow using symbols for name.