PATCH (mainline): address performance issue of libstdc++/7445
Loren James Rittle
rittle@latour.rsch.comm.mot.com
Wed Nov 13 07:36:00 GMT 2002
Although the intent was reasonable, there is no critical region to be
guarded within std::locale::classic(). The design pattern used is
singleton-called-before-threading-starts thus no locking protocol is
required other than the standard singleton construction guard. The
library code already has the undocumented assumption that threads
can't be started until all global objects have been constructed.
This patch was discussed back in August (around the 8th). Applied to
mainline and related PR closed.
libstdc++/7445
* src/locale.cc (std::locale::classic()): Weaken locking protocol.
Index: src/locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v
retrieving revision 1.69
diff -c -r1.69 locale.cc
*** src/locale.cc 11 Oct 2002 21:10:09 -0000 1.69
--- src/locale.cc 13 Nov 2002 07:08:48 -0000
***************
*** 367,375 ****
const locale&
locale::classic()
{
! static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;
! _STL_auto_lock __auto(__lock);
!
if (!_S_classic)
{
try
--- 367,373 ----
const locale&
locale::classic()
{
! // Locking protocol: singleton-called-before-threading-starts
if (!_S_classic)
{
try
More information about the Libstdc++
mailing list