Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77588 - in trunk: boost/thread/detail libs/thread/test libs/thread/test/threads/thread/constr
From: vicente.botet_at_[hidden]
Date: 2012-03-27 14:22:31


Author: viboes
Date: 2012-03-27 14:22:30 EDT (Tue, 27 Mar 2012)
New Revision: 77588
URL: http://svn.boost.org/trac/boost/changeset/77588

Log:
Thread: Added BOOST_EXPLICIT_MOVE
Text files modified:
   trunk/boost/thread/detail/move.hpp | 10 ++++++++++
   trunk/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp | 7 +++++++
   trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp | 8 +-------
   trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp | 13 +++++--------
   trunk/libs/thread/test/threads/thread/constr/move_pass.cpp | 14 +++++++++++---
   5 files changed, 34 insertions(+), 18 deletions(-)

Modified: trunk/boost/thread/detail/move.hpp
==============================================================================
--- trunk/boost/thread/detail/move.hpp (original)
+++ trunk/boost/thread/detail/move.hpp 2012-03-27 14:22:30 EDT (Tue, 27 Mar 2012)
@@ -61,6 +61,16 @@
 
 }
 
+#if ! defined BOOST_NO_RVALUE_REFERENCES
+//&& ! defined BOOST_NO_DELETED_FUNCTIONS
+#define BOOST_EXPLICIT_MOVE(RVALUE) RVALUE
+#elif ! defined BOOST_NO_RVALUE_REFERENCES && defined BOOST_MSVC
+#define BOOST_EXPLICIT_MOVE(RVALUE) RVALUE
+#else
+#define BOOST_EXPLICIT_MOVE(RVALUE) RVALUE.move()
+#endif
+
+
 #include <boost/config/abi_suffix.hpp>
 
 #endif

Modified: trunk/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp
==============================================================================
--- trunk/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp (original)
+++ trunk/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp 2012-03-27 14:22:30 EDT (Tue, 27 Mar 2012)
@@ -9,6 +9,8 @@
 #include "util.inl"
 #include "shared_mutex_locking_thread.hpp"
 
+#if defined BOOST_THREAD_USES_CHRONO
+
 #define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \
     { \
         boost::mutex::scoped_lock lock(mutex_name); \
@@ -266,3 +268,8 @@
 
     return test;
 }
+
+#else
+#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
+#endif
+

Modified: trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp 2012-03-27 14:22:30 EDT (Tue, 27 Mar 2012)
@@ -81,13 +81,7 @@
 int main()
 {
   {
-#if ! defined BOOST_NO_RVALUE_REFERENCES && ! defined BOOST_NO_DELETED_FUNCTIONS
- boost::thread t = boost::thread(MoveOnly(), MoveOnly());
-#elif ! defined BOOST_NO_RVALUE_REFERENCES && defined BOOST_MSVC
- boost::thread t = boost::thread(MoveOnly(), MoveOnly());
-#else
- boost::thread t = boost::thread(MoveOnly().move(), MoveOnly().move());
-#endif
+ boost::thread t = boost::thread( BOOST_EXPLICIT_MOVE(MoveOnly()), BOOST_EXPLICIT_MOVE(MoveOnly()) );
     t.join();
   }
   return boost::report_errors();

Modified: trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp 2012-03-27 14:22:30 EDT (Tue, 27 Mar 2012)
@@ -76,17 +76,14 @@
   }
 };
 
+MoveOnly MakeMoveOnly() {
+ return MoveOnly();
+}
+
 int main()
 {
   {
- // FIXME The following fails
-#if ! defined BOOST_NO_RVALUE_REFERENCES && ! defined BOOST_NO_DELETED_FUNCTIONS
- boost::thread t = boost::thread( MoveOnly() );
-#elif ! defined BOOST_NO_RVALUE_REFERENCES && defined BOOST_MSVC
- boost::thread t = boost::thread( MoveOnly() );
-#else
- boost::thread t = boost::thread( MoveOnly().move() );
-#endif
+ boost::thread t(( BOOST_EXPLICIT_MOVE(MakeMoveOnly()) ));
     t.join();
   }
   return boost::report_errors();

Modified: trunk/libs/thread/test/threads/thread/constr/move_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/move_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/move_pass.cpp 2012-03-27 14:22:30 EDT (Tue, 27 Mar 2012)
@@ -65,6 +65,10 @@
 int G::n_alive = 0;
 bool G::op_run = false;
 
+boost::thread make_thread() {
+ return boost::thread(G(), 5, 5.5);
+}
+
 int main()
 {
   {
@@ -76,10 +80,14 @@
     BOOST_TEST(t1.get_id() == id);
     BOOST_TEST(t0.get_id() == boost::thread::id());
     t1.join();
-#if 0
- BOOST_TEST(G::n_alive == 0);
-#endif
     BOOST_TEST(G::op_run);
   }
+ BOOST_TEST(G::n_alive == 0);
+ {
+ boost::thread t1((make_thread()));
+ t1.join();
+ BOOST_TEST(G::op_run);
+ }
+ BOOST_TEST(G::n_alive == 0);
   return boost::report_errors();
 }


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