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 <tbaldri...@gmail.com>:

> "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.
>
> Timothy
>
> On Fri, Jan 2, 2015 at 7:11 AM, Jörg Winter <jwin1...@gmail.com> wrote:
>
>> 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 example, an ArrayList is used for aggregating the
>> 'temporary' results for the step-function, so this mutable state is not
>> concerned with threading at all.
>> Why then is there a threading-concern with pv (the volatile!) ?
>>
>> As far as I understand, the step-function of a transducer is never(?)
>> accessed concurrently by more than 1 thread.
>>
>> Is volatile! necessary because transducers should be usable with
>> core.async ?
>> Or is it just an easy way to get a mutable object in Clojure ?
>>
>>
>> Best,
>> Joerg
>>
>> --
>> 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/d/optout.
>>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/CjxK7xEsOKQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/d/optout.

Reply via email to