On 03/16/2016 04:53 AM, Azat Khuzhin wrote:
It's better to enable locking for bufferevents anyway.

Are you sure it is ok to lock the bufferevents by our own lock? No need to
implement these
(http://www.wangafu.net/~nickm/libevent-book/Ref1_libsetup.html
<http://www.wangafu.net/%7Enickm/libevent-book/Ref1_libsetup.html>
specifically that section about “Locks and threading”)???

How about event_base? lock event_base similar to bufferevents?
I think that basic bufferevents locks must be enough (pthread on
linux/some stuff on win32), since std::thread is not about this, IOW it
is safe to synchronize via pthread's locks between them.

Thanks Azat. But I am still confused about how should I use the lock. In the documentation, there are related APIs about Lock :

evthread_use_pthreads(*void*): http://www.wangafu.net/~nickm/libevent-book/Ref1_libsetup.html <http://www.wangafu.net/%7Enickm/libevent-book/Ref1_libsetup.html>: see_locking and threading_


And you can also use the API for evbuffer:

evbuffer_enable_locking(evbuffer, null): http://www.wangafu.net/~nickm/libevent-book/Ref7_evbuffer.html <http://www.wangafu.net/%7Enickm/libevent-book/Ref7_evbuffer.html>: see _Evbuffer and Thread-safety._

What's the relationship between these two APIs. Before useing evbuffer_enable_locking(), should I first call

evthread_use_pthreads(*void*)? What's best way I use them? There is no example. I don't know how.


***********************************************************************
To unsubscribe, send an e-mail to [email protected] with
unsubscribe libevent-users    in the body.

Reply via email to