$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: anthony_at_[hidden]
Date: 2007-12-15 17:36:44
Author: anthonyw
Date: 2007-12-15 17:36:43 EST (Sat, 15 Dec 2007)
New Revision: 42087
URL: http://svn.boost.org/trac/boost/changeset/42087
Log:
explicit move functions for threads, with a test
Added:
   trunk/libs/thread/test/test_move_function.cpp   (contents, props changed)
Text files modified: 
   trunk/boost/thread/detail/move.hpp    |     6 ------                                  
   trunk/boost/thread/pthread/thread.hpp |    11 +++++++++++                             
   trunk/boost/thread/win32/thread.hpp   |    10 ++++++++++                              
   trunk/libs/thread/test/Jamfile.v2     |     1 +                                       
   4 files changed, 22 insertions(+), 6 deletions(-)
Modified: trunk/boost/thread/detail/move.hpp
==============================================================================
--- trunk/boost/thread/detail/move.hpp	(original)
+++ trunk/boost/thread/detail/move.hpp	2007-12-15 17:36:43 EST (Sat, 15 Dec 2007)
@@ -23,12 +23,6 @@
                 return &t;
             }
         };
-
-        template<typename T>
-        thread_move_t<T> thread_move(T& t)
-        {
-            return thread_move_t<T>(t);
-        }
     }
     
 }
Modified: trunk/boost/thread/pthread/thread.hpp
==============================================================================
--- trunk/boost/thread/pthread/thread.hpp	(original)
+++ trunk/boost/thread/pthread/thread.hpp	2007-12-15 17:36:43 EST (Sat, 15 Dec 2007)
@@ -169,6 +169,17 @@
         bool interruption_requested() const;
     };
 
+    inline detail::thread_move_t<thread> move(thread& x)
+    {
+        return x.move();
+    }
+    
+    inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> x)
+    {
+        return x;
+    }
+
+
     template<typename F>
     struct thread::thread_data<boost::reference_wrapper<F> >:
         detail::thread_data_base
Modified: trunk/boost/thread/win32/thread.hpp
==============================================================================
--- trunk/boost/thread/win32/thread.hpp	(original)
+++ trunk/boost/thread/win32/thread.hpp	2007-12-15 17:36:43 EST (Sat, 15 Dec 2007)
@@ -245,6 +245,16 @@
         bool interruption_requested() const;
     };
 
+    inline detail::thread_move_t<thread> move(thread& x)
+    {
+        return x.move();
+    }
+    
+    inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> x)
+    {
+        return x;
+    }
+
     template<typename F>
     struct thread::thread_data<boost::reference_wrapper<F> >:
         detail::thread_data_base
Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2	(original)
+++ trunk/libs/thread/test/Jamfile.v2	2007-12-15 17:36:43 EST (Sat, 15 Dec 2007)
@@ -36,6 +36,7 @@
     test-suite "threads"
         : [ thread-run test_thread.cpp ]
           [ thread-run test_thread_move.cpp ]
+          [ thread-run test_move_function.cpp ]
           [ thread-run test_mutex.cpp ]
           [ thread-run test_condition_notify_one.cpp ]
           [ thread-run test_condition_timed_wait_times_out.cpp ]
Added: trunk/libs/thread/test/test_move_function.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/test_move_function.cpp	2007-12-15 17:36:43 EST (Sat, 15 Dec 2007)
@@ -0,0 +1,42 @@
+// Copyright (C) 2007 Anthony Williams
+//
+//  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)
+#include <boost/thread/thread.hpp>
+#include <boost/test/unit_test.hpp>
+
+void do_nothing()
+{}
+
+void test_thread_move_from_lvalue_on_construction()
+{
+    boost::thread src(do_nothing);
+    boost::thread::id src_id=src.get_id();
+    boost::thread dest=boost::move(src);
+    boost::thread::id dest_id=dest.get_id();
+    BOOST_CHECK(src_id==dest_id);
+    BOOST_CHECK(src.get_id()==boost::thread::id());
+    dest.join();
+}
+
+boost::thread make_thread()
+{
+    return boost::thread(do_nothing);
+}
+
+void test_thread_move_from_function_return()
+{
+    boost::thread x=boost::move(make_thread());
+    x.join();
+}
+
+
+boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
+{
+    boost::unit_test_framework::test_suite* test =
+        BOOST_TEST_SUITE("Boost.Threads: thread move test suite");
+
+    test->add(BOOST_TEST_CASE(test_thread_move_from_lvalue_on_construction));
+    test->add(BOOST_TEST_CASE(test_thread_move_from_function_return));
+    return test;
+}