Re: core.async go-loop questions

2014-12-21 Thread Jonathon McKitrick
Well, my goal is to start a go-loop (if possible) at the root level of the code that simply parks and waits for a group of emails to be sent. When that happens, it would wake up and broadcast the result of the send operation via web socket back to the browser. I'd like to avoid starting that

Re: core.async go-loop questions

2014-12-21 Thread Chris Freeman
On Dec 21, 2014 7:17 AM, Jonathon McKitrick jmckitr...@gmail.com wrote: Well, my goal is to start a go-loop (if possible) at the root level of the code that simply parks and waits for a group of emails to be sent. When that happens, it would wake up and broadcast the result of the send

core.async go-loop questions

2014-12-20 Thread Jonathon McKitrick
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

Re: core.async go-loop questions

2014-12-20 Thread Erik Price
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

Re: core.async go-loop questions

2014-12-20 Thread Chris Freeman
I'm a little uncertain exactly what your code is trying to do, but I believe you're trying to notify a bunch of connections after your speaker notification emails are sent. In which case, I'd do something like this: (defn send-notifications [] (try

Re: core.async go-loop questions

2014-12-20 Thread Udayakumar Rayala
You could probably move setting the atom and calling my-wait-loop inside the try. (defn test-mailer [] (async/thread (try (do (reset! mailer-status (mailer/send-speaker-confirmation-notification 1 http://localhost;)) (my-wait-loop)) (catch