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

Re: [Libevent-users] std::threads



> 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.

Hi!

- evthread_use_pthreads() must be called always if intent to use
  threads, since it installs libevent to use pthread, IOW if you don't
  call it evbuffer_enable_locking() will return an error

- evbuffer_enable_locking() must be called if you are using evbuffer
  directly, not via bufferevents
- BEV_OPT_THREADSAFE is a flag for bufferevent that will make the
  thread-safe (and it's input/output evbuffer too, so they will share
  the same lock)

Regards,
Azat.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.