> Can anyone explain the relationship between swap! and reset! ?

swap! is for "CAS"

See: http://en.wikipedia.org/wiki/Compare-and-swap

In the examples here, you're fully replacing a value, so reset! is fine... 
assuming that the replacement value was not derived from the existing 
value. If the atom was deref-ed (via deref or the @ reader macro), that 
value is a perception of a potentially old state. Making a decision outside 
of an atomic swap operation would potentially be invalidated by another 
thread performing a conflicting mutation.

-- 
-- 
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/groups/opt_out.


Reply via email to