On Tue, Oct 12, 2010 at 07:22:33AM -0700, Damian Conway wrote: > > What we really need is some anecdotal evidence from folks who are actually > using threading in real-world situations (in *any* languages). What has worked > in practice? What has worked well? What was painful? What was error-prone? > And for which kinds of tasks? > > And we also need to stand back a little further and ask: is "threading" > the right approach at all? Do threads work in *any* language? Are there > better metaphors?
I've not used them, but Ruby 1.9 Fibers (continuations) and the EventMachine Reactor pattern seem interesting. http://www.igvita.com/2009/05/13/fibers-cooperative-scheduling-in-ruby/ http://www.igvita.com/2010/03/22/untangling-evented-code-with-ruby-fibers/ There's also an *excellent* screencast by Ilya Grigorik. It's from a Ruby/Rails perspective but he gives a good explanation of the issues. He shows how writing async code using callbacks rapidly gets complex and how continuations can be used to avoid that. Well worth a look: http://blog.envylabs.com/2010/07/no-callbacks-no-threads-ruby-1-9/ Tim. p.s. If short on time start at 15:00 and watch to at least 28:00.