OSDN Git Service

2009-04-25 Jonathan Wakely <jwakely.gcc@gmail.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / std / mutex
index f26acc0..3a22aab 100644 (file)
@@ -728,9 +728,10 @@ namespace std
     }
 #else
   extern function<void()> __once_functor;
     }
 #else
   extern function<void()> __once_functor;
+  extern unique_lock<mutex>* __once_functor_lock;
 
 
-  extern unique_lock<mutex>&
-  __get_once_functor_lock();
+  extern mutex&
+  __get_once_mutex();
 #endif
 
   extern "C" void __once_proxy();
 #endif
 
   extern "C" void __once_proxy();
@@ -745,18 +746,13 @@ namespace std
       __once_callable = &__bound_functor;
       __once_call = &__once_call_impl<decltype(__bound_functor)>;
 #else
       __once_callable = &__bound_functor;
       __once_call = &__once_call_impl<decltype(__bound_functor)>;
 #else
-      unique_lock<mutex>& __functor_lock = __get_once_functor_lock();
-      __functor_lock.lock();
+      unique_lock<mutex> __functor_lock(__get_once_mutex());
       __once_functor = bind(__f, __args...);
       __once_functor = bind(__f, __args...);
+      __once_functor_lock = &__functor_lock;
 #endif
 
       int __e = __gthread_once(&(__once._M_once), &__once_proxy);
 
 #endif
 
       int __e = __gthread_once(&(__once._M_once), &__once_proxy);
 
-#ifndef _GLIBCXX_HAVE_TLS
-      if (__functor_lock)
-       __functor_lock.unlock();
-#endif
-
       if (__e)
        __throw_system_error(__e);
     }
       if (__e)
        __throw_system_error(__e);
     }