You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by Rush Manbert <ru...@manbert.com> on 2009/05/01 01:57:39 UTC
C++ Library Mutex types - need some guidance
I am looking at the Mutex.h/cpp code and trying to figure out how to
implement the equivalent using Boost threads.
Things look pretty clear, except that the Mutex class can be
constructed three ways.
If the initializer is DEFAULT_INITIALIZER, then the implementation
initializes the mutex like this: pthread_mutex_init(pthread_mutex,
NULL) which is equivalent to initializing with type
PTHREAD_MUTEX_DEFAULT. This is the same as boost::mutex.
If the initializer is RECURSIVE_INITIALIZER, then the implementation
initializes the mutex with the type atribute
PTHREAD_MUTEX_RECURSIVE_NP which seems to be the same as using
PTHREAD_MUTEX_RECURSIVE, which is equivalent to boost::recursive_mutex.
Now comes the one I'm not so clear about.
If the initializer is ADAPTIVE_INITIALIZER, then the mutex is
initialized with type PTHREAD_MUTEX_ADAPTIVE_NP. From what I have
read, this seems to be functionally equivalent to using boost::mutex,
but I would be happy to hear from anyone who thinks differently.
Any help would be appreciated.
And yes, I'm working on a Windows port using Asio and Boost. Sockets
are done, threads are getting there, and testing is hard. :-) I'll
post more details later. But I need a little guidance right now from
someone who knows this pthread mutex stuff well.
- Rush
Re: C++ Library Mutex types - need some guidance
Posted by David Reiss <dr...@facebook.com>.
I can't find the reference, but, as I recall, PTHREAD_MUTEX_ADAPTIVE_NP
is an implementation strategy that doesn't change the standard
pthread_mutex semantics.
Rush Manbert wrote:
> I am looking at the Mutex.h/cpp code and trying to figure out how to
> implement the equivalent using Boost threads.
>
> Things look pretty clear, except that the Mutex class can be
> constructed three ways.
>
> If the initializer is DEFAULT_INITIALIZER, then the implementation
> initializes the mutex like this: pthread_mutex_init(pthread_mutex,
> NULL) which is equivalent to initializing with type
> PTHREAD_MUTEX_DEFAULT. This is the same as boost::mutex.
>
> If the initializer is RECURSIVE_INITIALIZER, then the implementation
> initializes the mutex with the type atribute
> PTHREAD_MUTEX_RECURSIVE_NP which seems to be the same as using
> PTHREAD_MUTEX_RECURSIVE, which is equivalent to boost::recursive_mutex.
>
> Now comes the one I'm not so clear about.
>
> If the initializer is ADAPTIVE_INITIALIZER, then the mutex is
> initialized with type PTHREAD_MUTEX_ADAPTIVE_NP. From what I have
> read, this seems to be functionally equivalent to using boost::mutex,
> but I would be happy to hear from anyone who thinks differently.
>
> Any help would be appreciated.
>
> And yes, I'm working on a Windows port using Asio and Boost. Sockets
> are done, threads are getting there, and testing is hard. :-) I'll
> post more details later. But I need a little guidance right now from
> someone who knows this pthread mutex stuff well.
>
> - Rush