Skip to content

Comment on Show HN: A threaded, TCP, key value store in Haskellparent

Comments

As far as I understand it, this simple example won't perform any better than if it were written using MVar. (i.e. it was explicitly locking reads and writes)

The difference is that `atomically` calls can be nested and still work. If you do an readMVar whilst that MVar is already locked in a function above you in your call stack you would have a deadlock.

So STM seems to be a smart way of keeping track which locks the current execution thread has so you never double lock.

At least in this case :)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.