On Apr 15, 4:12 pm, Robert Feldt <robert.fe...@gmail.com> wrote:
> Although I understand each of the concurrency "primitives"/systems
> (stm, agents, atoms, dynvars) in isolation I find it harder to choose
> wisely between them when designing/implementing specific algorithms
> and programs.
>
> Do you have any advice/tips for how to choose between Clojure's
> different concurrency constructs?
> How do you decide which construct to use for a particular algorithm/
> program?
>

I think "atom" with "swap!" is just a special case of "ref" with
"alter" when there is just one field to maintain concurrency on. Thus,
in general, you could use "ref" and "alter" wherever you use "atom"
and "swap!" (provided you wrap it in a do-sync statement).

However, "ref" provides "commute" which does not have a counterpart
for "atom".
And "atom" provides "compare-and-set! " which does not have a
counterpart for "dosync" of "ref".
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to