Boost logo

Boost-Commit :

From: anthony_at_[hidden]
Date: 2008-05-21 17:11:30


Author: anthonyw
Date: 2008-05-21 17:11:30 EDT (Wed, 21 May 2008)
New Revision: 45626
URL: http://svn.boost.org/trac/boost/changeset/45626

Log:
more rvalue reference stuff
Text files modified:
   trunk/boost/thread/win32/thread.hpp | 61 ++++++++++++++++++++++++++++++++++-----
   trunk/libs/thread/src/win32/thread.cpp | 3 +
   2 files changed, 55 insertions(+), 9 deletions(-)

Modified: trunk/boost/thread/win32/thread.hpp
==============================================================================
--- trunk/boost/thread/win32/thread.hpp (original)
+++ trunk/boost/thread/win32/thread.hpp 2008-05-21 17:11:30 EDT (Wed, 21 May 2008)
@@ -3,8 +3,8 @@
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
-// (C) Copyright 2007 Anthony Williams
-
+// (C) Copyright 2007-8 Anthony Williams
+
 #include <exception>
 #include <boost/thread/exceptions.hpp>
 #include <ostream>
@@ -38,6 +38,10 @@
     {
         struct thread_exit_callback_node;
         struct tss_data_node;
+
+ struct thread_data_base;
+ void intrusive_ptr_add_ref(thread_data_base * p);
+ void intrusive_ptr_release(thread_data_base * p);
         
         struct thread_data_base
         {
@@ -235,6 +239,24 @@
         {
             start_thread();
         }
+
+ thread(thread&& other)
+ {
+ thread_info.swap(other.thread_info);
+ }
+
+ thread& operator=(thread&& other)
+ {
+ thread_info=other.thread_info;
+ other.thread_info.reset();
+ return *this;
+ }
+
+ thread&& move()
+ {
+ return static_cast<thread&&>(*this);
+ }
+
 #else
         template <class F>
         explicit thread(F f):
@@ -249,6 +271,12 @@
         {
             start_thread();
         }
+
+ thread(detail::thread_move_t<thread> x);
+ thread& operator=(detail::thread_move_t<thread> x);
+ operator detail::thread_move_t<thread>();
+ detail::thread_move_t<thread> move();
+
 #endif
 
         template <class F,class A1>
@@ -257,7 +285,6 @@
         {
             start_thread();
         }
-
         template <class F,class A1,class A2>
         thread(F f,A1 a1,A2 a2):
             thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2)))
@@ -314,11 +341,6 @@
             start_thread();
         }
 
- thread(detail::thread_move_t<thread> x);
- thread& operator=(detail::thread_move_t<thread> x);
- operator detail::thread_move_t<thread>();
- detail::thread_move_t<thread> move();
-
         void swap(thread& x);
 
         class id;
@@ -353,10 +375,17 @@
         bool interruption_requested() const;
     };
 
+#ifdef BOOST_HAS_RVALUE_REFS
+ inline thread&& move(thread&& t)
+ {
+ return t;
+ }
+#else
     inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> t)
     {
         return t;
     }
+#endif
 
     template<typename F>
     struct thread::thread_data<boost::reference_wrapper<F> >:
@@ -373,6 +402,22 @@
             f();
         }
     };
+
+ template<typename F>
+ struct thread::thread_data<const boost::reference_wrapper<F> >:
+ detail::thread_data_base
+ {
+ F& f;
+
+ thread_data(const boost::reference_wrapper<F> f_):
+ f(f_)
+ {}
+
+ void run()
+ {
+ f();
+ }
+ };
     
 
     namespace this_thread

Modified: trunk/libs/thread/src/win32/thread.cpp
==============================================================================
--- trunk/libs/thread/src/win32/thread.cpp (original)
+++ trunk/libs/thread/src/win32/thread.cpp 2008-05-21 17:11:30 EDT (Wed, 21 May 2008)
@@ -247,9 +247,9 @@
         detach();
     }
     
+#ifndef BOOST_HAS_RVALUE_REFS
     thread::thread(detail::thread_move_t<thread> x)
     {
- lock_guard<mutex> lock(x->thread_info_mutex);
         thread_info=x->thread_info;
         x->thread_info=0;
     }
@@ -271,6 +271,7 @@
         detail::thread_move_t<thread> x(*this);
         return x;
     }
+#endif
 
     void thread::swap(thread& x)
     {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk