RFC: PATCH for thread-safe C++ static local initialization

Benjamin Kosnik bkoz@redhat.com
Mon Aug 23 18:09:00 GMT 2004


 
>How do people feel about extending the gthr interface to either support
>recursive mutexes (emulating in the gthr-* file if necessary) or thread_id,
>or both?

Both. 

Adding support for recursive mutexes should definitely be added, so if
you add this to gthr's interface, the target libraries can pick this
stuff up too and use it in a consistent way.  It would be nice if
libobjc, libsupc++, etc could all use the same interface.

Note, you have to add functions and typedefs to gthr-single.h too.

There is already extended support in libstdc++ for scoped locks in
bits/concurrence.h.  You might want to look at the way the underlying
mutex type is defined initialized, especially
__glibcxx_mutex_define_initialized. You could use something like this
instead of static mutexes, but it doesn't really matter, for
correctness.

Even "acquire_local_static_mutex" is better than acquire_1.

:)

-benjamin



More information about the Gcc-patches mailing list