On Fri, Sep 08, 2006 at 04:17:20PM -0700, Scott Lamb wrote: > On Sep 8, 2006, at 12:13 PM, William Ahern wrote: > >Ah. I was approaching it from another angle (one thread per event > >loop, and > >the question being how to inject events and balance events into > >each event > >loop). > > Like the first thing I described? Have you actually done this and had > any luck with it? I suppose I could give it a go, at least for a > simple balancing scheme.
What I've done in an MTA is use descriptor passing. A master process listens for connections and than sends them to it's children. I keep a tree of children, ordered by number of outstanding connections. When a child loses a connection it sends a message down a pipe so I can decrement it's connection count. But that's sort of heavy weight; ultimately I liked the idea because it provided robustness. I would like to try this scheme in a single-process, multiple thread environment. Each event loop could have an outstanding event listening on a pipe (just like the signal pipe in libevent). The thread accepting connections would select a thread to hand-off a connection and dump it into a queue, then signal that thread's event pipe. Actually, this is how I had assumed everybody else was doing it after I saw the event_base support go into the library. And also the source of my "poll on a mutex", because using a pipe for this also always seemed a little heavy weight. Though, I've never benchmarked so I have no right ;) _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users