Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / thread / scoped_thread.hpp
index c2da919..6cda931 100644 (file)
@@ -34,10 +34,10 @@ namespace boost
    *     boost::strict_scoped_thread<> t((boost::thread(F)));
    *
    */
-  template <class CallableThread = join_if_joinable>
+  template <class CallableThread = join_if_joinable, class Thread=::boost::thread>
   class strict_scoped_thread
   {
-    thread t_;
+    Thread t_;
     struct dummy;
   public:
 
@@ -47,13 +47,13 @@ namespace boost
      *
      */
 #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
-    template <class F, class ...Args, typename = typename disable_if<is_same<typename decay<F>::type, thread>, void* >::type>
+    template <class F, class ...Args, typename = typename disable_if<is_same<typename decay<F>::type, Thread>, void* >::type>
     explicit strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Args)... args) :
       t_(boost::forward<F>(f), boost::forward<Args>(args)...) {}
 #else
     template <class F>
     explicit strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f,
-        typename disable_if<is_same<typename decay<F>::type, thread>, void* >::type=0) :
+        typename disable_if<is_same<typename decay<F>::type, Thread>, void* >::type=0) :
       t_(boost::forward<F>(f)) {}
     template <class F, class A1>
     strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) :
@@ -73,7 +73,7 @@ namespace boost
      *
      * Effects: move the thread to own @c t.
      */
-    explicit strict_scoped_thread(BOOST_THREAD_RV_REF(thread) t) BOOST_NOEXCEPT :
+    explicit strict_scoped_thread(BOOST_THREAD_RV_REF(Thread) t) BOOST_NOEXCEPT :
     t_(boost::move(t))
     {
     }
@@ -111,14 +111,15 @@ namespace boost
    *     t.interrupt();
    *
    */
-  template <class CallableThread = join_if_joinable>
+  template <class CallableThread = join_if_joinable, class Thread=::boost::thread>
   class scoped_thread
   {
-    thread t_;
+    Thread t_;
     struct dummy;
   public:
 
-    typedef thread::id id;
+    typedef typename Thread::id id;
+    typedef typename Thread::native_handle_type native_handle_type;
 
     BOOST_THREAD_MOVABLE_ONLY( scoped_thread) /// Movable only
 
@@ -137,13 +138,13 @@ namespace boost
      */
 
 #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
-    template <class F, class ...Args, typename = typename disable_if<is_same<typename decay<F>::type, thread>, void* >::type>
+    template <class F, class ...Args, typename = typename disable_if<is_same<typename decay<F>::type, Thread>, void* >::type>
     explicit scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Args)... args) :
       t_(boost::forward<F>(f), boost::forward<Args>(args)...) {}
 #else
     template <class F>
     explicit scoped_thread(BOOST_THREAD_FWD_REF(F) f,
-        typename disable_if<is_same<typename decay<F>::type, thread>, void* >::type=0) :
+        typename disable_if<is_same<typename decay<F>::type, Thread>, void* >::type=0) :
       t_(boost::forward<F>(f)) {}
     template <class F, class A1>
     scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) :
@@ -163,12 +164,12 @@ namespace boost
      *
      * Effects: move the thread to own @c t.
      */
-    explicit scoped_thread(BOOST_THREAD_RV_REF(thread) t) BOOST_NOEXCEPT :
+    explicit scoped_thread(BOOST_THREAD_RV_REF(Thread) t) BOOST_NOEXCEPT :
     t_(boost::move(t))
     {
     }
 
-//    explicit operator thread()
+//    explicit operator Thread()
 //    {
 //      return boost::move(t_);
 //    }
@@ -213,7 +214,7 @@ namespace boost
     }
 
     // forwarded thread functions
-    inline thread::id get_id() const BOOST_NOEXCEPT
+    inline id get_id() const BOOST_NOEXCEPT
     {
       return t_.get_id();
     }
@@ -242,7 +243,7 @@ namespace boost
     }
 #endif
 
-    thread::native_handle_type native_handle()BOOST_NOEXCEPT
+    native_handle_type native_handle()BOOST_NOEXCEPT
     {
       return t_.native_handle();
     }
@@ -266,13 +267,13 @@ namespace boost
 
     static unsigned hardware_concurrency() BOOST_NOEXCEPT
     {
-      return thread::hardware_concurrency();
+      return Thread::hardware_concurrency();
     }
 
 #ifdef BOOST_THREAD_PROVIDES_PHYSICAL_CONCURRENCY
     static unsigned physical_concurrency() BOOST_NOEXCEPT
     {
-      return thread::physical_concurrency();
+      return Thread::physical_concurrency();
     }
 #endif
   };
@@ -280,12 +281,13 @@ namespace boost
   /**
    * Effects: swaps the contents of two scoped threads.
    */
-  template <class Destroyer>
-  void swap(scoped_thread<Destroyer>& lhs, scoped_thread<Destroyer>& rhs)
+  template <class Destroyer, class Thread >
+  void swap(scoped_thread<Destroyer, Thread>& lhs, scoped_thread<Destroyer, Thread>& rhs)
 BOOST_NOEXCEPT {
   return lhs.swap(rhs);
 }
 
+  typedef scoped_thread<> joining_thread;
 }
 #include <boost/config/abi_suffix.hpp>