[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] running libevent with multiple bases



On Tue, Jul 27, 2010 at 5:16 PM, Amy Hwang <amyomail@xxxxxxxxx> wrote:
> I have an architecture that reads and writes to a large number of
> sockets, where the sockets are spread over a number of threads, each
> with its own libevent base. Each socket is "owned" by a single
> libevent base, and the bases don't interact with each other. I opted
> for this architecture rather than a thread pool/job distribution one
> because most of the heavy lifting should be interacting with the
> sockets. I've read a couple of posts stating that multiple threads
> with bases aren't really supported in libevent, but what I have so far
> seems to be working.
>
> Does what I've described seem like a reasonable thing to do in
> libevent 2.0.5?

It sounds reasonable to me.

> I've also enabled pthreads just to be safe, although
> I'm not exactly sure pthreads is actually contributing to anything.

Probably nothing for the architecture you describe, so long as you're
right about the kind of isolation you're getting. Remember that making
sure that threads never interact with each other's bases is not
(alas!) as simple as making sure that they don't refer to the bases
directly.  Each thread must also never touch (e.g., add, delete, or
activate) any event associated with another event base, or touch any
object (bufferevent, evdns_base) whose events are associated with
other event bases, or so on.

Personally, I think it's safer just to enable threads.

peace,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.