Hi Meikel,

On 25 Jul 2011, at 22:46, Meikel Brandmeyer wrote:

> Am 25.07.2011 um 23:12 schrieb Sam Aaron:
> 
> Since this is callback based, you can't return a value. Do you want more 
> something like a polling solution? Then you'll have to roll your own with an 
> atom and a clojure.lang.PersistentQueue.

Sorry, I should have been more specific. The callback-based watchers are cool, 
but I don't believe they specifically address my problem (which I don't believe 
I sufficiently explained from the outset).

Hopefully this is a more succinct and specific description. Is there a way to 
write the following in a thread safe manner without using a transaction:

(def a (ref 1))

(defn update-and-check-whether-modified?
  [update-fn]
  (let [changed? (dosync
                  (let [old-a @a
                        new-a (alter a update-fn)]
                    (not= old-a new-a)))]
    changed?))


Sam

---
http://sam.aaron.name


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