This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Andrew Pollard <Andrew dot Pollard at brooks-pri dot com>
- Cc: bkoz at gcc dot gnu dot org, shurik at sequoiap dot com, libstdc++ at gcc dot gnu dot org
- Date: Fri, 2 Aug 2002 09:08:35 -0700
- Subject: Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications
- Organization: Red Hat / Chicago
- References: <3D4A8E5F.1090205@brooks-pri.com>
- Reply-to: bkoz at redhat dot com
> There was a reason that I locked the entire method, so that _S_classic
> is guaranteed to only be set once. With the code right now, there are
> a couple of problems....
Yikes.
I think the original patch was better. Sorry. Here's an update on
current sources. Let me know if this is what will work.
Index: src/locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v
retrieving revision 1.62
diff -c -p -r1.62 locale.cc
*** src/locale.cc 31 Jul 2002 19:34:08 -0000 1.62
--- src/locale.cc 2 Aug 2002 16:20:20 -0000
*************** namespace std
*** 284,294 ****
const locale&
locale::classic()
{
if (!_S_classic)
{
- static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;
_STL_auto_lock __auto(__lock);
-
try
{
// 26 Standard facets, 2 references.
--- 284,293 ----
const locale&
locale::classic()
{
+ static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;
if (!_S_classic)
{
_STL_auto_lock __auto(__lock);
try
{
// 26 Standard facets, 2 references.