Re: working with agents and atoms - a beginner question

2010-06-17 Thread Ryan Waters
After reading your posts and thinking "wouldn't it be nice to just kick off a thread and not care about the return value" I recall Rich using/liking [1] the Java Executor framework [2]. I looked at clojure.lang.Agent and saw it used there, too. It's tricky because I wouldn't want to lean on Java

Re: working with agents and atoms - a beginner question

2010-06-16 Thread Meikel Brandmeyer
Hi, Am 16.06.2010 um 22:34 schrieb Christophe Grand: > I agree, it still feels a little dirty to use a future without caring > about the return value but on the positive said you get an easy way to > block and wait for the tread to finish (deref) and you also get > future-done?, future-cancel and

Re: working with agents and atoms - a beginner question

2010-06-16 Thread Christophe Grand
On Wed, Jun 16, 2010 at 10:20 PM, Meikel Brandmeyer wrote: > The typical solution for your problem would probably be: > > (->> long-running-function-with-recur Thread. .start) > > This starts you function in a dedicated thread and you can save the overhead > of send-off and use recur directly. I'

Re: working with agents and atoms - a beginner question

2010-06-16 Thread Meikel Brandmeyer
Hi, Am 15.06.2010 um 23:27 schrieb Ryan Waters: > Thank you for pointing that out. I notice your style is similar to > Rich's in his ant.clj [1] which seems like the kind of solution that > might be used in other functional and/or lisp languages. Do you know > if that's the case with self-calli

Re: working with agents and atoms - a beginner question

2010-06-16 Thread Ryan Waters
On Wed, Jun 16, 2010 at 12:17 AM, Christophe Grand wrote: > Hi Ryan, > > On Tue, Jun 15, 2010 at 6:01 PM, Ryan Waters 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)

Re: working with agents and atoms - a beginner question

2010-06-16 Thread Ryan Waters
Thank you for pointing that out. I notice your style is similar to Rich's in his ant.clj [1] which seems like the kind of solution that might be used in other functional and/or lisp languages. Do you know if that's the case with self-calling functions and agents? However, isn't there more overhe

Re: working with agents and atoms - a beginner question

2010-06-16 Thread Ryan Waters
On Tue, Jun 15, 2010 at 12:23 PM, Shawn Hoover wrote: > > On Tue, Jun 15, 2010 at 12:01 PM, Ryan Waters 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 >>

Re: working with agents and atoms - a beginner question

2010-06-15 Thread Christophe Grand
Hi Ryan, On Tue, Jun 15, 2010 at 6:01 PM, Ryan Waters 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.

Re: working with agents and atoms - a beginner question

2010-06-15 Thread Meikel Brandmeyer
Hi, besides the answer you got from Shawn, I'd like to question your use of the agent system. This is not the way it is supposed to be used. To model a processing loop with agents you should send the action back to the agent itself. (def running? (atom true)) (defn process [agent-state step]

Re: working with agents and atoms - a beginner question

2010-06-15 Thread Shawn Hoover
On Tue, Jun 15, 2010 at 12:01 PM, Ryan Waters 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. > > Unfo

working with agents and atoms - a beginner question

2010-06-15 Thread Ryan Waters
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 un