This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [c++0x] mutex and condition variable initializers


> I realised recently that in C++0x mode the new uniform initialization
> syntax allows this to work for the posix thread model:
> 
> mutex() : _M_mutex __GTHREAD_MUTEX_INIT
> { }
> 
> instead of
> 
> mutex()
> {
>    __native_type __tmp = __GTHREAD_MUTEX_INIT;
>   _M_mutex = __tmp;
> }

Smart, you.
 
> Would it be worth adding a configure check to see if that works with
> the chosen threading model and using it when possible?

Well, since the actual code is conditional on
_GTHREAD_MUTEX_INIT/_GTHREAD_COND_INIT, and you are only dealing with
half of it, how are you planning on dealing with the other part of the
condition? ie, _GTHREAD_MUTEX_INIT_FUNCTION? Don't see how this would
end up being a win.

Although it is indeed clever.

-benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]