This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[c++0x] mutex and condition variable initializers
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 13 May 2009 21:05:28 +0100
- Subject: [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;
}
On most (all?) pthreads implementations it expands to something like
_M_mutex{ 0,... } which is a valid initialization in C++0x. The same
applies to std::condition_variable and __GTHREAD_COND_INIT.
Would it be worth adding a configure check to see if that works with
the chosen threading model and using it when possible?
Jonathan