On Tue, Dec 28, 2010 at 11:16 PM, Jason Wolfe <jawo...@berkeley.edu> wrote:
> Use transients?
>
> (dotimes [_ 10]
>  (let [m (atom (transient {}))
>        r (range 1e5)]
>   (time
>    (doseq [i r]
>      (swap! m assoc! i 2)))))

Since transients enforce single-threadedness, there's no reason to put
it in an atom.  You're right that would work for the truly
single-threaded scenario.  I'm more interested right now in the
scenario of "multi-threaded, low-contention, only occasionally need a
snapshot (for iteration without blocking)", so I hadn't really thought
in terms of transients, but I appreciate the reminder.  Maybe some of
the new pod work will eventually help here since it will reportedly
allow for other sorts of ways to manage the mutable contents.  Good
thinking,

Mark

-- 
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

Reply via email to