In your example yes, but you could make it atomic by placing the functionality in a function of it's own:
;; queue processing actions (defn process-item [queue] (println "Processed item:" (peek queue)) (pop queue)) ;; usage (let [queue (atom (into PersistentQueue/EMPTY [1 2 3]))] (swap! queue process-item) ; prints 1 (swap! queue process-item) ; prints 2 (swap! queue process-item)) ; prints 3 Probably better examples but that's the basic idea. Allen On Wed, Nov 9, 2011 at 8:46 PM, Takahiro Hozumi <fat...@googlemail.com> wrote: > Hi, > > To avoid peeking same element of a queue, I think PersistentQueue must > be stored in ref not atom. > Is this correct? > > ;;Ref: safe > (dosync > (let [item (peek @r)] > (alter r pop) > item)) > > ;Atom: unsafe > (let [item (peek @a)] > (swap! a pop) > item)) > > Thanks. > > -- > 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 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