OSDN Git Service

2011-03-14 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / std / thread
index d5bbf6e..e43c126 100644 (file)
@@ -1,6 +1,6 @@
 // <thread> -*- C++ -*-
 
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -22,7 +22,7 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
-/** @file thread
+/** @file include/thread
  *  This is a Standard C++ Library header.
  */
 
 
 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
 
-namespace std
+namespace std _GLIBCXX_VISIBILITY(default)
 {
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   /**
    * @defgroup threads Threads
    * @ingroup concurrency
@@ -98,7 +100,7 @@ namespace std
     {
       __shared_base_type       _M_this_ptr;
 
-      inline virtual ~_Impl_base();
+      virtual ~_Impl_base();
 
       virtual void _M_run() = 0;
     };
@@ -126,16 +128,14 @@ namespace std
     thread(thread&& __t)
     { swap(__t); }
 
-    template<typename _Callable>
-      explicit thread(_Callable __f)
-      {
-       _M_start_thread(_M_make_routine<_Callable>
-                       (std::forward<_Callable>(__f)));
-      }
-
     template<typename _Callable, typename... _Args>
+      explicit 
       thread(_Callable&& __f, _Args&&... __args)
-      { _M_start_thread(_M_make_routine(std::bind(__f, __args...))); }
+      {
+        _M_start_thread(_M_make_routine(std::bind<void>(
+                std::forward<_Callable>(__f),
+                std::forward<_Args>(__args)...)));
+      }
 
     ~thread()
     {
@@ -195,8 +195,6 @@ namespace std
       }
   };
 
-  inline thread::_Impl_base::~_Impl_base() = default;
-
   inline void
   swap(thread& __x, thread& __y)
   { __x.swap(__y); }
@@ -238,12 +236,16 @@ namespace std
        return __out << __id._M_thread;
     }
 
+_GLIBCXX_END_NAMESPACE_VERSION
+
   /** @namespace std::this_thread
    *  @brief ISO C++ 0x entities sub namespace for thread.
    *  30.2.2 Namespace this_thread.
    */
   namespace this_thread
   {
+  _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
     /// get_id
     inline thread::id
     get_id() { return thread::id(__gthread_self()); }
@@ -282,10 +284,13 @@ namespace std
        ::nanosleep(&__ts, 0);
       }
 #endif
+
+  _GLIBCXX_END_NAMESPACE_VERSION
   }
 
   // @} group threads
-}
+
+} // namespace
 
 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1