libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications
Benjamin Kosnik
bkoz@redhat.com
Fri Aug 2 09:21:00 GMT 2002
> 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.
More information about the Libstdc++
mailing list