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

Re: [Libevent-users] std::threads





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: 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: 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 majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.