On Tue, Jun 15, 2010 at 12:23 PM, Shawn Hoover <shawn.hoo...@gmail.com> wrote:
>
> On Tue, Jun 15, 2010 at 12:01 PM, Ryan Waters <ryan.or...@gmail.com> wrote:
>>
>> I'm working with the code at the following gist and also pasted below:
>>
>> http://gist.github.com/421550
>>
>> I'd like to have execution of a separate thread (agent) continue
>> running until it sees the atom 'running' change to false.
>>
>> Unfortunately, the program doesn't return from the send-off but
>> to my understanding it should.  Why won't it return?  I'm using
>> clojure 1.1.
>>
>> TIA
>>
>> ;;;;;;;;;;;;;;;;
>>
>> (ns nmanage)
>>
>> (def running (atom true))
>>
>> (defn process
>>  []
>>  (when @running
>>    (prn "hi")
>>    (Thread/sleep 1000))
>>  (recur))
>>
>> ;;;
>> (send-off (agent nil) (process))
>>
>> (do
>>  (prn "this won't print - execution doesn't make it this far")
>>  (Thread/sleep 2000)
>>  (reset! running false))
>>
>
> It looks like you're passing the result of calling (process) as an argument
> to send-off. Try just (send-off (agent nil) process) to pass the process fn
> as a value.
>

Doh!  I should have caught that  : )

Thank you for your help!

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