Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77551 - in trunk/libs/thread/test: . threads/thread/constr
From: vicente.botet_at_[hidden]
Date: 2012-03-25 18:31:13


Author: viboes
Date: 2012-03-25 18:31:11 EDT (Sun, 25 Mar 2012)
New Revision: 77551
URL: http://svn.boost.org/trac/boost/changeset/77551

Log:
Thread: Update F_pass and Frvalue tests for compilers that doesn't support rvalue references or delete constructors.
Text files modified:
   trunk/libs/thread/test/Jamfile.v2 | 13 +++++++++
   trunk/libs/thread/test/threads/thread/constr/F_pass.cpp | 11 ++++++++
   trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp | 50 +++++++++++++++++++++++++++++++++++----
   trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp | 30 ++++++++++++++++--------
   4 files changed, 86 insertions(+), 18 deletions(-)

Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2012-03-25 18:31:11 EDT (Sun, 25 Mar 2012)
@@ -43,6 +43,15 @@
     ;
 }
 
+rule thread-run-lib2 ( sources : name )
+{
+ return
+ [ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
+ : : :
+ : $(name)_lib ]
+ ;
+}
+
 
 rule thread-compile-fail-V2 ( sources : reqs * : name )
 {
@@ -309,7 +318,7 @@
           [ thread-run2 ./threads/thread/assign/move_pass.cpp : thread__assign__move_p ]
           [ thread-compile-fail-V2 ./threads/thread/constr/copy_fail.cpp : : thread__constr__copy_f ]
           [ thread-run2 ./threads/thread/constr/default_pass.cpp : thread__constr__default_p ]
- [ thread-run2 ./threads/thread/constr/F_pass.cpp : thread__constr__F_p ]
+ [ thread-run-lib2 ./threads/thread/constr/F_pass.cpp : thread__constr__F_p ]
           [ thread-run2 ./threads/thread/constr/Frvalue_pass.cpp : thread__constr__Frvalue_p ]
           #[ thread-run2 ./threads/thread/constr/FrvalueArgs_pass.cpp : thread__constr__FrvalueArgs_p ]
           [ thread-run2 ./threads/thread/constr/move_pass.cpp : thread__constr__move_p ]
@@ -356,4 +365,6 @@
     # [ thread-run2 ./sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_for_pass.cpp : upgrade_lock__cons__move_ctor_shared_lock_for_p ]
     # [ thread-run2 ./sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_until_pass.cpp : upgrade_lock__cons__move_ctor_shared_lock_until_p ]
     #;
+
+
 }

Modified: trunk/libs/thread/test/threads/thread/constr/F_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/F_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/F_pass.cpp 2012-03-25 18:31:11 EDT (Sun, 25 Mar 2012)
@@ -17,16 +17,17 @@
 
 // template <class F, class ...Args> thread(F f, Args... args);
 
-#include <boost/thread/thread.hpp>
 #include <new>
 #include <cstdlib>
 #include <cassert>
+#include <boost/thread/thread.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
 unsigned throw_one = 0xFFFF;
 
 void* operator new(std::size_t s) throw (std::bad_alloc)
 {
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
   if (throw_one == 0) throw std::bad_alloc();
   --throw_one;
   return std::malloc(s);
@@ -34,6 +35,7 @@
 
 void operator delete(void* p) throw ()
 {
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
   std::free(p);
 }
 
@@ -96,6 +98,7 @@
     BOOST_TEST(f_run == true);
   }
   f_run = false;
+#ifndef BOOST_MSVC
   {
     try
     {
@@ -109,6 +112,7 @@
       BOOST_TEST(!f_run);
     }
   }
+#endif
   {
     BOOST_TEST(G::n_alive == 0);
     BOOST_TEST(!G::op_run);
@@ -118,6 +122,7 @@
     BOOST_TEST(G::op_run);
   }
   G::op_run = false;
+#ifndef BOOST_MSVC
   {
     try
     {
@@ -131,14 +136,18 @@
     {
       throw_one = 0xFFFF;
       BOOST_TEST(G::n_alive == 0);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
       BOOST_TEST(!G::op_run);
     }
   }
+#endif
   {
     BOOST_TEST(G::n_alive == 0);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
     BOOST_TEST(!G::op_run);
     boost::thread t(G(), 5, 5.5);
     t.join();
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
     BOOST_TEST(G::n_alive == 0);
     BOOST_TEST(G::op_run);
   }

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-25 18:31:11 EDT (Sun, 25 Mar 2012)
@@ -25,31 +25,69 @@
 
 class MoveOnly
 {
- MoveOnly(const MoveOnly&);
-public:
+#ifndef BOOST_NO_DELETED_FUNCTIONS
+ public:
+ MoveOnly(const MoveOnly&)=delete;
+ MoveOnly& operator=(MoveOnly const&);
+#else
+ private:
+ MoveOnly(MoveOnly&);
+ MoveOnly& operator=(MoveOnly&);
+ public:
+#endif
   MoveOnly()
   {
   }
 #ifndef BOOST_NO_RVALUE_REFERENCES
   MoveOnly(MoveOnly&&)
   {}
- void operator()(MoveOnly&&)
+#else
+#if defined BOOST_THREAD_USES_MOVE
+ MoveOnly(boost::rv<MoveOnly>&)
+ {}
+ MoveOnly& operator=(boost::rv<MoveOnly>&)
+ {
+ return *this;
+ }
+ operator ::boost::rv<MoveOnly>&()
   {
+ return *static_cast< ::boost::rv<MoveOnly>* >(this);
+ }
+ operator const ::boost::rv<MoveOnly>&() const
+ {
+ return *static_cast<const ::boost::rv<MoveOnly>* >(this);
+ }
+ ::boost::rv<MoveOnly>& move()
+ {
+ return *static_cast< ::boost::rv<MoveOnly>* >(this);
+ }
+ const ::boost::rv<MoveOnly>& move() const
+ {
+ return *static_cast<const ::boost::rv<MoveOnly>* >(this);
   }
 #else
+#error
   MoveOnly(detail::thread_move_t<MoveOnly>)
   {}
- void operator()(detail::thread_move_t<MoveOnly>)
- {
- }
+#endif
 #endif
 
+ void operator()()
+ {
+ }
 };
 
+
 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
     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-25 18:31:11 EDT (Sun, 25 Mar 2012)
@@ -25,14 +25,16 @@
 
 class MoveOnly
 {
-#ifndef BOOST_NO_RVALUE_REFERENCES
- MoveOnly(const MoveOnly&);
+#ifndef BOOST_NO_DELETED_FUNCTIONS
+ public:
+ MoveOnly(const MoveOnly&)=delete;
+ MoveOnly& operator=(MoveOnly const&);
 #else
+ private:
   MoveOnly(MoveOnly&);
   MoveOnly& operator=(MoveOnly&);
+ public:
 #endif
-public:
- typedef int boost_move_emulation_t;
   MoveOnly()
   {
   }
@@ -55,6 +57,14 @@
   {
     return *static_cast<const ::boost::rv<MoveOnly>* >(this);
   }
+ ::boost::rv<MoveOnly>& move()
+ {
+ return *static_cast< ::boost::rv<MoveOnly>* >(this);
+ }
+ const ::boost::rv<MoveOnly>& move() const
+ {
+ return *static_cast<const ::boost::rv<MoveOnly>* >(this);
+ }
 #else
   MoveOnly(detail::thread_move_t<MoveOnly>)
   {}
@@ -66,17 +76,17 @@
   }
 };
 
-MoveOnly MakeMoveOnly() {
- MoveOnly x;
- return boost::move(x);
-}
 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() );
- //boost::thread t = boost::thread( MakeMoveOnly() );
- //boost::thread t (( boost::move( MoveOnly() ) ));
+#else
+ boost::thread t = boost::thread( MoveOnly().move() );
+#endif
     t.join();
   }
   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