Re: Use of volatile! in stateful transducers

2017-04-08 Thread Alexander Gunnarson
EDIT: Transducers are not safe in `fold` contexts either: (let [f (fn [i x] (println (str "i " i " " (Thread/currentThread))) (flush) x) r-map-indexed #(r/folder %2 (map-indexed %1))] (->> [6 7 8 9 10] (r-map-indexed f) (r/fold 1 (fn ([] (vector)) ([x] x) ([a b] (into a b)))

Re: Use of volatile! in stateful transducers

2017-04-08 Thread Alexander Gunnarson
I was wondering the same thing, Jörg. This thread talks about it as well. I posted a note there which I will reproduce here for your convenience: I think it's safe to assume that since `ArrayList` uses unsynchronized mutability inte

Re: Use of volatile! in stateful transducers

2015-01-02 Thread Jörg Winter
So if I'd need that extra performance, say in a private library of transducers not intended to be shared with other Clojure developers, it is perfectly Ok to use a java.lang.Object instead of a volatile, right ? Am Freitag, 2. Januar 2015 15:59:36 UTC+1 schrieb tbc++: > > "As far as I understan

Re: Use of volatile! in stateful transducers

2015-01-02 Thread Jörg Winter
So if I'd need that extra performance, say in a private library of transducers not intended to be shared with other Clojure developers, it is perfectly Ok to use a java.lang.Object instead of a volatile, right ? J 2015-01-02 15:59 GMT+01:00 Timothy Baldridge : > "As far as I understand, the step

Re: Use of volatile! in stateful transducers

2015-01-02 Thread Timothy Baldridge
"As far as I understand, the step-function of a transducer is never(?) accessed concurrently by more than 1 thread." It's actually "one thread at a time". And you're right, stuff like Core.async may bounce a transducer between several different threads, but only 1 thread "owns" it at a given time.

Use of volatile! in stateful transducers

2015-01-02 Thread Jörg Winter
Hi, As seen in this example of a stateful transducer... http://crossclj.info/ns/org.clojure/clojure/latest/clojure.core.html#_partition-by ... I am wondering what is the concrete motivation behind using 'volatile!' instead of say a simple (mutable) Java-Object wrapper ? In the partition-all exam