This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications


> 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.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]