Would some of this difficulty be ameliorated by calling memoize on the function that you use? That way, if it's an expensive function, and the value hasn't changed, it's just looked up rather than recalculated.
- DAemon On Fri, May 18, 2012 at 6:28 AM, Stuart Sierra <the.stuart.sie...@gmail.com>wrote: > I think the point with `commute` is to allow for more concurrency at the > expense of more computation. > > If you want assurance that your function is only called once, you can use > `alter`. > > Keep in mind that *any* code in a Ref transaction has the potential to be > called more than once if there's a conflict. > > All this doesn't mean that it's impossible to avoid the duplicate > computation on `commute`. The code to study would be here: > > > https://github.com/clojure/clojure/blob/8fda34e4c77cac079b711da59d5fe49b74605553/src/jvm/clojure/lang/LockingTransaction.java#L459 > > -S > > > -- > 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 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