如何在 Clojure 中查看我的 STM 中的回滚次数? [英] How can I see the number of rollbacks in my STM in Clojure?

查看:12
本文介绍了如何在 Clojure 中查看我的 STM 中的回滚次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Clojure 中查看我的 STM 中的回滚次数?

How can I see the number of rollbacks in my STM in Clojure?

推荐答案

你不能……除非你愿意作弊:

You can't... unless you are willing to cheat:

(defmacro spy-dosync [& body]
  `(let [retries# (atom -1)
         result# (dosync
                   (swap! retries# inc)
                   ~@body)]
     (println "retries count:" @retries#)
     result#))

然后将您的 dosync 替换为 spy-dosync.

and then replace your dosync by a spy-dosync.

这篇关于如何在 Clojure 中查看我的 STM 中的回滚次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆