ref-count only increment when one of the following occurs: * min-history > 0 * ref-read-faults > 0 && current-ref-history-count < max-history-count.
;; ref-count increment because min-history > 0 (let [r (ref 1 :min-history 1) f1 (future (dosync (Thread/sleep 1000) (println "ref-count: " (ref-history-count r)) @r)) f2 (future (dosync (ref-set r 2)))] [@f1 @f2]) ;; ref-count increment because there's read faults (let [r (ref 1) f1 (future (dosync (Thread/sleep 1000) (println "ref-count: " (ref-history-count r)) @r)) f2 (future (dosync (ref-set r 2))) f3 (future (dosync (Thread/sleep 1500) (ref-set r 2)))] [@f1 @f2]) Checkout related clojure source here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LockingTransaction.java#L321-L326 On 2013-5-30, at 下午10:05, Josh Kamau <joshnet2...@gmail.com> wrote: > (def my-ref (ref 1)) > > > > (defn update-my-ref > [new-value] > (dosync > (alter my-ref #(+ % new-value)) > (ref-history-count my-ref))) > > Hi guys ; > > I am trying to understand (ref-history-count ref) . I thought it counts the > number of "old" values in the ref. But in all my tests, its always returning > zero. How is it used? > > Josh > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.