wow. I wonder if I could use this for the quicksort I was talking about. I would need to have the function being added as a job be able to add it's own jobs recursively . . . .and kill jobs when they are done. But do you have to sleep, or is there a way to join the children when they are done? And is there a way to throttle the total number of agents? I'm lazy, so if this is something I should be reading about on my own, I totally understand. I'm wondering if this post is enough of a clue to get started is all.
So any frame in the stack is responsible for taking any sequence of at least one element and: 1) first element is the pivot. 2) if there are elements less than pivot, make a job to quicksort them when there is an available agent. 3) fire off a quicksort for stuff greater than pivot when there is an available agent. 4) join back with the two child tasks and grab their now sorted subsequences 5) kill the child jobs 6) glue the subsequences with the pivot in the middle 7) return to the parent code At first, there will only be one thread for the first pass, but the number will grow as subtasks fire sub-sub tasks. I am sure this is a silly way to sort because the threadspawning time is so much longer than the filtering time, but it's just an exercise. Is that example (provided in the link) enough knowledge to get started on this? Thanks. On Thu, Jan 22, 2009 at 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. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---