I can't claim this is better, but it is shorter - I simply removed
what seemed like some unnecessary syntax:

(def data (ref ()))
(def consuming (ref false))

(defn producer []
  (if (dosync (if (not @consuming)
                (alter data conj 1)))
    (recur)))

(defn consumer []
  (dosync (ref-set consuming true))
  (println "Consuming started, " (count @data) " items to consume."))

(doseq [i (range 100)]
  (future-call producer))
(Thread/sleep 350)
(consumer)


For a better answer I think some more detail on the actual problem
being solved is required.

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