问题描述
我正在研究Clojure中的并发编程。
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.
只有 ref 用于协调更新,因此在执行更改时使用 dosync 宏。
Only ref is used for coordinated updates , so dosync macro is used when performing changes.
所以很明显,STM引擎在这一点上涉及。
So it is obvious that STM engine is involved at this point.
只是想清楚下面的怀疑我有,
Just wanted to be clear about following doubt I have,
推荐答案
STM与代理相关,发送
,发送
和 send-via
在 dosync
块中调用时,只会生效一次(且如果)事务成功提交。
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.
STM和原子之间没有关系。
There is no relationship between the STM and Atoms.
这篇关于Clojure STM与原子和代理形式有关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!