[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] lock question
On Thu, Jul 29, 2010 at 4:23 AM, Avi Bab <abab@xxxxxxxxxxxxx> wrote:
>
>
> Does writing to an output evbuffer (specifocally I use
> evbuffer_add_reference) of a bufferevent attempt to acquire the event_base’s
> lock?
Usually not. It does acquire the bufferevent's lock. It *might* have
to tell the bufferevent to start writing if it wasn't previously
writing, which (if the bufferevent is using events to write) will make
the bufferevent's write event have to get added.
> I.e., if thread A calls evbuffer_add_reference(bufferevent_get_output(bev),
> data, data_len, cleanupfn, extra) - will it block while thread B that
> dispatches on bev’s event_base is handling active events?
Handling active events doesn't block; the event_base releases its lock
when it's running callbacks, and only grabs it again when it needs to
find the next callback.
yrs,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.