[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Help with progress thread
Email is frequently a horrid method of communication, I fear. Let me dig deeper into this and see what I can find, rather than continuing to draw on your time.
Putting all the notes together, it looks like libevent does internally exactly what we were doing externally, so the duplication may well not be required. Some of our code is probably leftover from when we were not calling the event_use_threads function, combined with some confusion over what some of the code snippets were intended to do.
Regardless, I do appreciate your explanations. Digging into the internals of a code base to determine what/how things are done is always difficult.
On Nov 12, 2010, at 9:29 PM, Nick Mathewson wrote:
> On Fri, Nov 12, 2010 at 10:47 AM, Ralph Castain <rhc@xxxxxxxxxxxx> wrote:
>> Hi Nick
>>
>> Appreciate the help. Shame on me for the buglet re open.
>>
>> Using your revisions, I was able to get this to work with our integration (i.e., using the opal abstractions). I'm a little puzzled by the procedure, though, so if you don't mind my tasking your patience, I do have a question.
>>
>> I gather that the standard procedure in threaded scenarios is to signal the "progress thread" every time a new event is assigned to that event base by another thread.
>
> No. There is internal notification code that is called when you
> event_add or event_del an event from another thread, and this code is
> supposed wake up the thread that's in the event loop automatically so
> it can restart the loop. See my messages of Nov 9 to Nov 10.
>
>> Your "event_active" method is nicer than writing a pipe - thanks for pointing it out - but bottom line is that you have to use an "update" event to force the event lib out of event_loop and then re-enter event_loop. True?
>
> False... I think? I think I am confused as to what you think is going on here.
>
> Look at the code in evthread-test.c. The event_add for the write
> event happens from thread 1 (the initial thread) while thread 2 (the
> one running event_base_loop) is running the event loop. If I needed
> to do something special in order to make an event_add get counted, it
> would already be too late.
>
> Here is a simpler variation. The main thread launches an
> event_base_loop thread to watch for events, waits, then adds an event
> to the event_base_loop thread. Then it shows that it can trigger the
> event several times without having done anything besides event_add()
> to tell the new thread about it. Then it waits for events to process
> as before, then it tells the subthread to exit using
> event_base_loopexit (which also adds an internal event to the
> event_base), then it returns. *At no point is any magic required to
> add the events, even though they are added from a different thread.*
>
> If this isn't what you had in mind, could you post a small sample of
> the code that you think Libevent doesn't support, but should?
>
> yrs,
> --
> Nick
> <evthread-test2.c>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.