[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Forwarding events to a different event base.
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] Forwarding events to a different event base.
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Tue, 26 Oct 2010 21:54:53 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 26 Oct 2010 21:54:58 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=BQSo72Yp9LPYw7w3fsoJvnv9cqeqt1PrDX6L3fq9hZU=; b=joHbbwmrVYCi0lYpkqmQH3t//GOaIMAK2p3QPjkW5JiDCfotAqlF3iGZLmeBSIzk78 1jlIFJSrkML5O+t2Pnm1DUoL9HlveH8kazIQtQ9lpyepJMnjCVbfWQox4s/Fcp7qsg26 JFKtJeXMXzIR8kJRHwrlRNIK2anUTfiFiCkqs=
- 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 :content-transfer-encoding; b=e26C807JiF7cIA/gTsBOzXi92P2ElO+veQTUljehLPuJDsmW0fxoPUyaMq4/GcjVpP jC1l+MMefSeOhAJa/d+A7UxIVzW+vYaypIpT18NVq5Bm77uFEodpN5oYv87fc+Ws68sI qskTUL6xvWQhTEe8Sl5KiZGqiApTFhmbEiCmM=
- In-reply-to: <8798B713B20949C1AE3A4EDF712B5BAD@Office>
- References: <8798B713B20949C1AE3A4EDF712B5BAD@Office>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Tue, Oct 26, 2010 at 8:22 AM, Kelly Brock <Kerby@xxxxxxxxxxx> wrote:
> Hi Folks,
>
> So, given the latest rc does not support listener sockets under Win
> IOCP (unless that has changed),
Are you talking about the IOCP based evconnlistener stuff? It's
supposed to be working; if it isn't, you should open a bug on the
tracker.
> something I would like to do is push
> listener events into a different event base. The simple reasoning is that I
> would like my worker threads to get both the read/write/timer and the
> listener events from a single location. I can see the "assign to a
> different event base" item but I'm unsure as to if it does what I would like
> and/or is safe for this purpose, the documentation on that item seems
> lacking in "why" it exists.
Which items are you talking about here? Which documentation? Have you
seen the documentation at http://www.wangafu.net/~nickm/libevent-book/
?
> The other option I see to solve this is to cache the event data into
> a new structure and call event_base_once on the other event base in order to
> pass it across. I assume I can also use this solution to pass anything else
> I might want to add into and extend the event loop with?
If I understand right, this is your actual question: You have code in
one thread that wants some other code to execute as part of the thread
running the event_base loop.
The easiest way to do this is to create a dummy event with fd==-1,
events==0, and with callback and callback arguments whatever you like.
You can do this with event_new or event_assign or however you usually
create events. Once you have done that, you can make the event active
in its base (so that its callback will get run) by calling
event_active on it.
If you're going to be calling event_active from another thread,
remember that you'll need to be using Libevent 2.0, and you'll need to
set up threading functions. (See chapter 1 of that manual.)
hoping this helps,
--
Nick Mathewson
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.