OSDN Git Service

2010-02-25 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / std / mutex
index eb71c76..7a1e259 100644 (file)
@@ -1,6 +1,6 @@
 // <mutex> -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -33,7 +33,7 @@
 #pragma GCC system_header
 
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
-# include <c++0x_warning.h>
+# include <bits/c++0x_warning.h>
 #else
 
 #include <tuple>
@@ -386,18 +386,6 @@ namespace std
   extern const try_to_lock_t   try_to_lock;
   extern const adopt_lock_t    adopt_lock;
 
-  /** 
-   *  @brief Thrown to indicate errors with lock operations.
-   *
-   *  @ingroup exceptions
-   */
-  class lock_error : public exception
-  {
-  public:
-    virtual const char*
-    what() const throw();
-  };
-
   /// @brief  Scoped lock idiom.
   // Acquire the mutex here with a constructor call, then release with
   // the destructor call in accordance with RAII style.
@@ -567,7 +555,7 @@ namespace std
       }
 
       void
-      swap(unique_lock&& __u)
+      swap(unique_lock& __u)
       {
        std::swap(_M_device, __u._M_device);
        std::swap(_M_owns, __u._M_owns);
@@ -586,7 +574,7 @@ namespace std
       owns_lock() const
       { return _M_owns; }
 
-      /* explicit */ operator bool () const
+      explicit operator bool() const
       { return owns_lock(); }
 
       mutex_type*
@@ -603,16 +591,6 @@ namespace std
     swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y)
     { __x.swap(__y); }
 
-  template<typename _Mutex>
-    inline void
-    swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y)
-    { __x.swap(__y); }
-
-  template<typename _Mutex>
-    inline void
-    swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y)
-    { __x.swap(__y); }
-
   template<int _Idx>
     struct __unlock_impl
     {
@@ -729,8 +707,11 @@ namespace std
 #else
   extern function<void()> __once_functor;
 
-  extern unique_lock<mutex>&
-  __get_once_functor_lock();
+  extern void
+  __set_once_functor_lock_ptr(unique_lock<mutex>*);
+
+  extern mutex&
+  __get_once_mutex();
 #endif
 
   extern "C" void __once_proxy();
@@ -741,20 +722,20 @@ namespace std
     call_once(once_flag& __once, _Callable __f, _Args&&... __args)
     {
 #ifdef _GLIBCXX_HAVE_TLS
-      auto __bound_functor = bind(__f, __args...);
+      auto __bound_functor = std::bind<void>(__f, __args...);
       __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();
-      __once_functor = bind(__f, __args...);
+      unique_lock<mutex> __functor_lock(__get_once_mutex());
+      __once_functor = std::bind<void>(__f, __args...);
+      __set_once_functor_lock_ptr(&__functor_lock);
 #endif
 
       int __e = __gthread_once(&(__once._M_once), &__once_proxy);
 
 #ifndef _GLIBCXX_HAVE_TLS
       if (__functor_lock)
-       __functor_lock.unlock();
+        __set_once_functor_lock_ptr(0);
 #endif
 
       if (__e)