On Tuesday, April 5, 2016 at 6:51:59 PM UTC-7, tbc++ wrote:
>
> If it all seems confusing, do not despair, there's two things that will
> handle the vast majority of the use cases you may have:
>
> 1) `future` - spawns a thread that runs the body of the future (
> https://clojuredocs.org/clojure.core/future)
> 2) `atom` and `swap!` - Used to store data that needs to be shared between
> threads and updated concurrently (
> https://clojuredocs.org/clojure.core/atom) these are built on top of CAS,
> which itself is foundation upon which most of concurrent programming is
> built. (https://en.wikipedia.org/wiki/Compare-and-swap)
>
> Those two primitives alone will handle 90% of the use cases you will run
> into as a new clojure developer. The rest of the stuff (agents, thread
> pools, refs, vars, cps/core.async) can all come in time, but you will use
> them much less often than threads and atoms. So read up on those two and
> feel free to come back with any questions you may have.
>
>
Okay I've been taking a look at these docs and some articles around them. I
think where most of my confusion arises from expecting to see some form of
threading or process spawning. Instead I see something like:
user=> (def a (atom #{}))#'user/a
user=>(swap! a conj :tag)#{:tag}
user=> @a#{:tag}
Which is showing a mutable value in a language that (from what I understand)
values immutability. The thing that's throwing me off is that none of the
examples I'm finding actually shows threaded code. I guess what I'm looking for
is that kind of example to see how it all fits together.
> Timothy
>
>
> On Tue, Apr 5, 2016 at 7:24 PM, Chris White <[email protected]
> <javascript:>> wrote:
>
>> I was doing some reading of code recently to help me get up to speed with
>> Clojure. One of the libraries I randomly came across dealt with parallelism
>> and I had a hard time following along with it. To try and wrap my head
>> around things I did a quick search and found this article:
>>
>>
>> http://www.thattommyhall.com/2014/02/24/concurrency-and-parallelism-in-clojure/
>>
>> I'm not sure how authoritative this is based on my current experience,
>> but needless to say I was a bit overwhelmed. That said is there any sort of
>> introductory material that list members have used to help get them into how
>> Clojure deals with concurrency and parallelism? I also don't mind anything
>> that's not specifically using Clojure but will at least help me understand
>> the concepts behind how Clojure does it. Thanks again for any and all help!
>>
>> - Chris White (@cwgem)
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.