[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] levent 2.x multithreaded?
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] levent 2.x multithreaded?
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Sat, 20 Mar 2010 01:55:25 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sat, 20 Mar 2010 01:55:30 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=zmTtgM8u1hXjjSbcnwAgzBzKxUwUFYWU+tc5WzCCHfo=; b=VtfZPUfq1ZjDiE/OVMKXcf5KfXgN51P/xoSnBqFot0tHo3VPYEfFD2LiZN2daeTInr R1i1+SIXu148zP/XrjBO/VVzN0vUJbFNvpg+bGtLy0GuIY+CWWOxvyLio/MdfBrTUNGP RuhOfgZizJIwS5FrFewMQO7xVqrPghb/w7hCI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=I/Hq+urW8V0ZkxKAsD4/MTGM3R3uJmWmmFjs7KxkwPlwIlFH3s8EGwZUVrglwdzgMH rBoAkSoTJCsZPk9Bbz0zVJGRycX+P94G3IX93Ge/GuJIQXLhc2sE1Ex4ZvRGcPqqhT3G hFwTRoIZK47dXDq/Xg/NjusSDbecoFO/E5mwc=
- In-reply-to: <4BA25A43.9020307@xxxxxxxxxxxx>
- References: <4BA25A43.9020307@xxxxxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Thu, Mar 18, 2010 at 12:52 PM, Roman Puls <puls@xxxxxxxxxxxx> wrote:
> Hi Folks,
>
> I thought libevent would work multithreaded in the sense we can create
> (let's say) 4 worker threads that poll the same event_base. Is that
> assumption wrong?
Yes.
Each event base can only have one thread invoking
event_base_dispatch() on it (or event_base_loop, etc). Libevent's
multithreading support in 2.0 is such that it's possible to manipulate
an event_base (or most things) from multiple threads (assuming you've
got locking enabled) but the main loop for each event_base still runs
in just a single thread.
If you want to have multiple worker threads, you need to either
1) have a separate event_base for each one
2) have an event_base running in one thread whose callbacks assign
work (through some reasonable model) to the other threads.
3) get Libevent's event_base_dispatch() function to support thread pools.
Long-term, we do indeed hope to do 3, but it almost certainly won't
happen for Libevent 2.0; maybe in 2.1 or 2.2.
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.