On Thu, Jan 22, 2009 at 2:52 PM, Greg Harman <ghar...@gmail.com> wrote:
>
> I like the example, and I should be able to adapt it. I do have one
> question about the example (probably not related to agents:
>
> ; queue up some work to be done
> (defn add-job [func]
>  (let [a (agent nil)]
>    (send a (fn [_] (func)))
>    (swap! jobs #(conj %1 a))))
>
> What is the notation fn [_]? I can't seem to find any documentation
> for what _ as a function argument means...

It's a conventional name for unused/ignored arguments.


>
> On Jan 22, 6:14 am, Greg Harman <ghar...@gmail.com> wrote:
>> Thanks Tim, I'll have a look at that.
>>
>> To clarify my use case, I was thinking of events that can be processed
>> sequentially but that may take a non-trivial amount of time to
>> complete (both CPU and IO bound at different stages of processing) so
>> it's ideal to have a thread pool to process different tasks in
>> parallel, even though they are independent. (That's step one. Step two
>> will be spreading that "thread pool" out over multiple JVMs running on
>> different hardware).
>>
>> On Jan 22, 2:39 am, Timothy Pratley <timothyprat...@gmail.com> wrote:
>>
>> > Hi Greg
>>
>> > Here is a proof of concept of one approach you could 
>> > take:http://groups.google.com/group/clojure/web/job-queue.clj
>>
>> > A set of agents are maintained to represent computation jobs. When the
>> > results are gathered, the agent is thrown away. I think using multiple
>> > agents in this way could be quite convenient as it means the jobs can
>> > be done in parallel.
>>
>> > If you run the script from the command line you should get something
>> > like this:
>> > C:\java>clj job-queue.clj
>> > (4 3)
>> > (0 nil Hi mum)
>> > Which are the results of multiple queued computations taken at two
>> > subsequent points in time.
>>
>> > From your post it wasn't clear to me if your 'events' imply sequential
>> > processing (which could be achieved with a single agent).
>>
>> > Regards,
>> > Tim.
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

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