On Mon, Aug 3, 2009 at 5:44 AM, Christophe Grand wrote:
> I think Mark's code exhibits a bug:
>
> (def my-ref (ref 1))
>
> (dosync
> (ref-set my-ref 5)
> (commute my-ref inc)) ; returns 6
>
> (println "my-ref =" @my-ref) ; prints 7
>
> since my-ref is ref-set, my-ref is in LockingTransaction/s
I think Mark's code exhibits a bug:
(def my-ref (ref 1))
(dosync
(ref-set my-ref 5)
(commute my-ref inc)) ; returns 6
(println "my-ref =" @my-ref) ; prints 7
since my-ref is ref-set, my-ref is in LockingTransaction/sets but its
current value in LockingTransaction/vals is set by commute to 6
On Sun, Aug 2, 2009 at 8:54 PM, Mark Volkmann wrote:
>
> On Sun, Aug 2, 2009 at 5:45 PM, Rich Hickey wrote:
>>
>> On Sun, Aug 2, 2009 at 3:20 PM, Mark Volkmann
>> wrote:
>>>
>>> The doc for commute says "At the commit point of the transaction, sets
>>> the value of ref to be:
>>> (apply fun most-
On Sun, Aug 2, 2009 at 5:45 PM, Rich Hickey wrote:
>
> On Sun, Aug 2, 2009 at 3:20 PM, Mark Volkmann
> wrote:
>>
>> The doc for commute says "At the commit point of the transaction, sets
>> the value of ref to be:
>> (apply fun most-recently-committed-value-of-ref args)".
>>
>> Looking at the sou
On Sun, Aug 2, 2009 at 3:20 PM, Mark Volkmann wrote:
>
> The doc for commute says "At the commit point of the transaction, sets
> the value of ref to be:
> (apply fun most-recently-committed-value-of-ref args)".
>
> Looking at the source code in LockingTransaction.java, that doesn't
> seem to alwa
I've been thinking about this more. Suppose I do something like this.
(def my-ref (ref 1))
(defn f1 []
(dosync
(ref-set my-ref 10)))
(defn f2 []
(dosync
(ref-set my-ref 5)
(commute my-ref #(inc %
(let [t1 (Thread. f1)
t2 (Thread. f2)]
(.start t1)
(.start t2)
(.j