Re: commute misunderstanding

2010-02-19 Thread Аркадий Рост
It seems I have an example that shows difference between commute and alter. Here it is: (defn my-inc [x] (dosync (Thread/sleep 1000) (inc x))) alter*** (def x (ref 0)) (do (def fut (future (do (Thread/sleep 300) (dosync (alter x inc)) @x))) (dosync (println @x)(alter x my-inc)(pr

Re: commute misunderstanding

2010-02-18 Thread Laurent PETIT
2010/2/18 Аркадий Рост : > hmm..but in what way I can write code to demonstrate the difference? You must reproduce the race conditions. An idea is to start 2 transactions in 2 different threads, while making the first one sleep sufficiently so you're sure the second one will commit first. Simply

Re: commute misunderstanding

2010-02-18 Thread Аркадий Рост
hmm..but in what way I can write code to demonstrate the difference? -- 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

Re: commute misunderstanding

2010-02-18 Thread Laurent PETIT
2010/2/18 Аркадий Рост : > Hi! > I don't understand difference between commute and alter. In fact I > don't understand how can I get different results by changing alter to > commute in code.I've read that the in-transaction value with commute > is that it may differ from the post-commit value, as t