Thanks for finding that video! "If you're sending something over the network, it always has to happen on the reactor thread."
He's referring to the send_data<http://eventmachine.rubyforge.org/EventMachine/Connection.html#M000287>method. It's true that you can only write data back to clients connected to your EventMachine server on the reactor thread. That's why defer<http://eventmachine.rubyforge.org/EventMachine.html#M000486>runs the operation block on the thread pool and the callback block on the reactor thread. But if you open your own blocking IO socket to some other server, like ActiveRecord does, you're free to do IO on threads in the EventMachine thread pool. I found this example from James Tucker, one of the EventMachine maintainers, that demonstrates something very similar to what I showed last night. It's using DataMapper rather than ActiveRecord, but it shows the query happening on the thread pool with the results being written back to the client on the reactor thread. https://groups.google.com/d/msg/eventmachine/pyjbJ4H3f7I/RTrnxEShTm4J David On Wed, Apr 18, 2012 at 10:36 AM, Sean McKibben <gfxli...@graphex.com> wrote: > Great talk, David. At one point I mentioned something about IO having to be > done on the reactor thread, but didn't know why. I still don't, but that > advice came from 14:00 in to this video: > http://www.confreaks.com/videos/555-scotlandruby2011-introduction-to-eventmachine-and-evented-programming > "in production weird errors if you do IO from a non-reactor thread, yadda, > yadda" (paraphrase) > > So it might just be voodoo paranoia, but "when you're dealing with > concurrency, there's nothing wrong with being paranoid" > > Thanks again for the great presentation. The state machine approach really > helped my thinking about EM coding (and good concurrency patterns in > general). > > Sean > > On Apr 17, 2012, at 10:46 PM, David Graham wrote: > > Thanks to everyone who came out tonight. I had a great time presenting! > > The slides are on Speaker Deck: > http://speakerdeck.com/u/dgraham/p/eventmachine-server-design-with-xmpp > > David > > > On Mon, Apr 16, 2012 at 6:23 PM, Marty Haught <mghau...@gmail.com> wrote: > > Tomorrow is our April meeting for Boulder Ruby. We'll be meeting on > > Tuesday the 17th at 7pm at Pivotal Labs (directions below). They are > > generous hosting food and drink for the meeting so thank them for > > their support. Food will arrive at 6:45. > > > David Graham will lead off our meeting talking about building an XMPP > > server with Event Machine. He'll dig into the streaming XML parsers, > > state machines, asynchronous queues, fibers, and thread pools needed > > to build a scalable, event-based chat server. > > > Following that, David Kapp will speak about client-side template > > rendering. He’ll talk about what client-side rendering is, why you > > should care about it, give some examples, and talk about how to fit it > > into your projects. There are a lot of different libraries for this > > out there, and while the examples will be given using Handlebars.js, > > the general ideas should apply to any of them. > > > http://boulderruby.org/meetings/2012/03/26/april-2012/ > > > I look forward to seeing you all there. > > > Cheers, > > Marty Haught > > http://boulderruby.org > > > Directions: > > Pivotal Labs > > 1701 Pearl St > > Boulder, CO 80302 > > > Use the 17th St entrance closer to the alley on the NE side of the > > intersection. You should see the Pivotal Labs logo in the window. The > > meeting space is upstairs. > > > URL to google maps: http://bit.ly/fNTcZf > > _______________________________________________ > > Bdrg-members mailing list > > Bdrg-members@rubyforge.org > > http://rubyforge.org/mailman/listinfo/bdrg-members > > _______________________________________________ > Bdrg-members mailing list > Bdrg-members@rubyforge.org > http://rubyforge.org/mailman/listinfo/bdrg-members > >
_______________________________________________ Bdrg-members mailing list Bdrg-members@rubyforge.org http://rubyforge.org/mailman/listinfo/bdrg-members