News for hackers. Stuff that matters.
Re:Ask HN: What are some cool but obscure data structures yo... by moonchrome on Friday July 22, 2022 @06:04AM (#32190346)
Just make sure Map access is thread safe - awaiting promises is - but updating/reading map keys usually isn't.
Re:Ask HN: What are some cool but obscure data structures yo... by skrebbel on Friday July 22, 2022 @07:58AM (#32190998)
Yep, in multithreaded langs you just want to use a ConcurrentMap or whatever the stdlib has for this. The write is very brief because you only write the promise and not eg keep a proper lock on the key until the result has arrived, so no need for a fancier datastructure.
Re:Ask HN: What are some cool but obscure data structures yo... by unrealhoang on Friday July 22, 2022 @06:18AM (#32190416)
js is single-threaded so no problem there.
Re:Ask HN: What are some cool but obscure data structures yo... by moonchrome on Friday July 22, 2022 @06:23AM (#32190441)
Since OP mentioned Mutexes I assumed he's dealing with multithreaded code, but with JS this works as advertised :)