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

Re: [Libevent-users] Forwarding events to a different event base.



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.