Does Clojure STM has a relationship with atom and agent forms?

混江龙づ霸主 提交于 2019-12-24 04:22:58

问题


I am looking into the Concurrency programming in Clojure . http://clojure.org/concurrent_programming

I got to know that atom, ref and agent forms are used to maintain program state.

Only ref is used for coordinated updates , so dosync macro is used when performing changes.

So it is obvious that STM engine is involved at this point.

Just wanted to be clear about following doubt I have,

Does Clojure STM has a relationship with atom and agent forms too? or are they just utilized java.util.concurrent.atomic capabilities ?


回答1:


The STM is related to Agents in that send, send-off and send-via, when called inside a dosync block, only take effect once (and if) the transaction successfully commits.

There is no relationship between the STM and Atoms.



来源:https://stackoverflow.com/questions/18976062/does-clojure-stm-has-a-relationship-with-atom-and-agent-forms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!