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

[Libevent-users] Thread safety with Evbuffers and Bufferevents

Hello all,


I’d like to use a socket based bufferevent to perform asynchronous writing to the underlying socket:

One thread, X, adds data to the output  evbuffer (either by evbuffer_reserve_space+ evbuffer_commit_space or by evbuffer_add_reference) and another thread, Y, dispatches on the bufferevent’s event_base (i.e., actually sends the data via the socket).

My questions are –

Does thread X need to perform locking on the evbuffer?

If so then how can I have thread Y synchronize on the same locks?

I assume that setting the bufferevent option BEV_OPT_THREADSAFE will not affect the “direct” access to  the evbuffer by X.