------- Comment #5 from rguenth at gcc dot gnu dot org 2009-05-10 12:12 ------- Btw, from a quick look the global mutex could be easily replaced with atomic updates of the reference counts (it seems they already are atomic) and atomic exchanges of the locale pointer.
Atomically fetching the current global locale and adding a reference to it (huh, it looks like we leak locales that become global? at lest we do not drop references from the global locale we replace in locale::global(const locale&)) is easy (pointer reads are atomic if the pointer is naturally aligned) - a special case would appear if we ever can get a stale (zero reference) locale pointer, but that doesn't seem to be the case (see the previous comment in parens). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40088