This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
PATCH (mainline): address performance issue of libstdc++/7445
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 Nov 2002 08:59:48 -0600 (CST)
- Subject: PATCH (mainline): address performance issue of libstdc++/7445
- Reply-to: rittle at labs dot mot dot com
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