Tim*_*teo 8 functional-programming transactions clojure
我想分析Clojure程序与C中锁定版本的行为.我想跟踪的一个指标是我的Clojure程序的中止事务总数.
唯一的问题是我不能在我所处的事务上下文之外变异变量.我想要做的是:
(dosync
(try
(alter my_num inc)
(catch Throwable t
(do
(alter total_aborts inc)
(println "Caught " (.getClass t))
(throw t)))))
Run Code Online (Sandbox Code Playgroud)
当然,如果交易没有完成,total_aborts永远不会增加!那我该怎么做呢?谢谢!