Part of what makes core.async great is that you don't have to use atoms to communicate between threads in every case. For your case, I don't see what using an atom gets you. It seems like you could replace the atom with a channel, and put values on the channel whenever mail is sent. Your code will be almost unchanged, except you'd replace your atom reset with a channel put.
e On Sat, Dec 20, 2014 at 10:17 PM, Jonathon McKitrick <jmckitr...@gmail.com> wrote: > I'd like to implement a thread that will send an email, then send a > response via websocket to the client when the send completes. > > (defn my-wait-loop [] > (async/go-loop [status (async/<! @mailer-status)] > (if status > (do > (println "Ready to send " status) > (doseq [chan @connections] > (println "Channel" chan) > (send! chan (pr-str "Done" status))) > (recur (async/<! @mailer-status))) > (println "Go away")))) > > (defn test-mailer [] > ;;(my-wait-loop) > (reset! mailer-status > (async/thread > (try > (mailer/send-speaker-confirmation-notification 1 " > http://localhost") > (catch Exception e > (println (.getMessage e)))) > "Success"))) > > I would like to have the go-loop inside my-wait-loop run at all times, > waiting for mailer-status to have a value. > But I believe that can never happen, since the go-loop is waiting on an > empty channel, and the reset! with the mailer will replace the channel with > a new one after the emails are sent. > > Is there a batter way to do this, without needing to call my-wait-loop > before the email thread is dispatched? > > -- > 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/d/optout. > -- 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/d/optout.