3 ms·
STM is pointless if it only works on just the tiniest possible transactions. Wrap a lock around the tiny transactions and call it a day. Without the composabili
by jerf 15y ago
STM is pointless if it only works on just the tiniest possible transactions. Wrap a lock around the tiny transactions and call it a day. Without the composability, STM has no appeal.
Yes, you still don't want long-running transactions and you will seek to minimize them, but the entire point is that you can write an STM action that may cross a few modules coming from different authors and put a selection of such actions together, and one must only apply normal amounts of thought to such minimization instead of insane amounts of thought and effort.
It may be worth pointing out that I've made non-trivial use of the Haskell implementation. For Haskellers and Clojure programmers, STM isn't a pie-in-the-sky tech, it's a relatively straightforward library, because if you can manage effects or build it into your language very early (respectively), STM is almost boringly easy to implement. It's only hard (to the point of apparent impossibility) if you try to bodge it onto an existing imperative language.