Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77870 - in trunk: boost/thread libs/thread/test libs/thread/test/sync/futures/packaged_task
From: vicente.botet_at_[hidden]
Date: 2012-04-09 19:21:17


Author: viboes
Date: 2012-04-09 19:21:16 EDT (Mon, 09 Apr 2012)
New Revision: 77870
URL: http://svn.boost.org/trac/boost/changeset/77870

Log:
Thread: rollback the last changes in packaged_task
Text files modified:
   trunk/boost/thread/future.hpp | 96 +++++++++++----------------------------
   trunk/libs/thread/test/Jamfile.v2 | 2
   trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp | 2
   trunk/libs/thread/test/test_ml.cpp | 11 ++++
   4 files changed, 39 insertions(+), 72 deletions(-)

Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-04-09 19:21:16 EDT (Mon, 09 Apr 2012)
@@ -1698,26 +1698,18 @@
         struct task_object:
             task_base<R>
         {
+ private:
+ task_object(task_object&);
+ public:
             F f;
-#ifndef BOOST_NO_RVALUE_REFERENCES
- task_object(R(*f_)()):
+ task_object(F const& f_):
                 f(f_)
             {}
-// task_object(const F &f_):
-// f(f_)
-// {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
             task_object(F&& f_):
               f(boost::forward<F>(f_))
             {}
-#else
-// task_object(R(*f_)()):
-// f(f_)
-// {}
- task_object(F const& f_):
- f(f_)
- {}
-
-#if defined BOOST_THREAD_USES_MOVE
+#elif defined BOOST_THREAD_USES_MOVE
             task_object(boost::rv<F>& f_):
                 f(boost::move(f_))
             {}
@@ -1726,8 +1718,6 @@
                 f(f_)
             {}
 #endif
-#endif
-
             void do_run()
             {
                 try
@@ -1749,25 +1739,18 @@
         struct task_object<void,F>:
             task_base<void>
         {
+ private:
+ task_object(task_object&);
+ public:
             F f;
-#ifndef BOOST_NO_RVALUE_REFERENCES
- task_object(void(*f_)()):
+ task_object(F const& f_):
                 f(f_)
             {}
-// task_object(const F& f_):
-// f(f_)
-// {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
             task_object(F&& f_):
               f(boost::forward<F>(f_))
             {}
-#else
-// task_object(void(*f_)()):
-// f(f_)
-// {}
- task_object(F const& f_):
- f(f_)
- {}
-#if defined BOOST_THREAD_USES_MOVE
+#elif defined BOOST_THREAD_USES_MOVE
             task_object(boost::rv<F>& f_):
                 f(boost::forward<F>(f_))
             {}
@@ -1776,7 +1759,6 @@
                 f(f_)
             {}
 #endif
-#endif
 
             void do_run()
             {
@@ -1798,7 +1780,6 @@
 
     }
 
-
     template<typename R>
     class packaged_task
     {
@@ -1823,22 +1804,19 @@
 
         // construction and destruction
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
         explicit packaged_task(R(*f)()):
             task(new detail::task_object<R,R(*)()>(f)),future_obtained(false)
         {}
         template <class F>
+ explicit packaged_task(F const& f):
+ task(new detail::task_object<R,F>(f)),future_obtained(false)
+ {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ template <class F>
         explicit packaged_task(F&& f):
             task(new detail::task_object<R,F>(boost::forward<F>(f))),future_obtained(false)
         {}
 #else
- explicit packaged_task(R(*f)()):
- task(new detail::task_object<R,R(*)()>(f)),future_obtained(false)
- {}
- template <class F>
- explicit packaged_task(F const& f):
- task(new detail::task_object<R,F>(f)),future_obtained(false)
- {}
 #if defined BOOST_THREAD_USES_MOVE
         template <class F>
         explicit packaged_task(boost::rv<F>& f):
@@ -1853,48 +1831,38 @@
 #endif
 
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
-#ifndef BOOST_NO_RVALUE_REFERENCES
         template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a, F&& f)
+ packaged_task(boost::allocator_arg_t, Allocator a, const F& f)
         {
           typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(boost::forward<F>(f)), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(f), D(a2, 1) );
+ std::cout << __FILE__ ":"<<__LINE__<<std::endl;
           future_obtained = false;
         }
-// template <class F, class Allocator>
-// packaged_task(boost::allocator_arg_t, Allocator a, const F& f)
-// {
-// typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
-// A2 a2(a);
-// typedef thread_detail::allocator_destructor<A2> D;
-//
-// task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(f), D(a2, 1) );
-// std::cout << __FILE__ ":"<<__LINE__<<std::endl;
-// future_obtained = false;
-// }
-#else
-#if defined BOOST_THREAD_USES_MOVE
+#ifndef BOOST_NO_RVALUE_REFERENCES
         template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a, boost::rv<F>& f)
+ packaged_task(boost::allocator_arg_t, Allocator a, F&& f)
         {
           typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(boost::move(f)), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(boost::forward<F>(f)), D(a2, 1) );
           future_obtained = false;
         }
+#else
+#if defined BOOST_THREAD_USES_MOVE
         template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a, F const& f)
+ packaged_task(boost::allocator_arg_t, Allocator a, boost::rv<F>& f)
         {
           typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(f), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(boost::move(f)), D(a2, 1) );
           future_obtained = false;
         }
 #else
@@ -1908,16 +1876,6 @@
           task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(boost::forward<F>(f)), D(a2, 1) );
           future_obtained = false;
         }
- template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a, F const& f)
- {
- typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
- A2 a2(a);
- typedef thread_detail::allocator_destructor<A2> D;
-
- task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(f), D(a2, 1) );
- future_obtained = false;
- }
 #endif // BOOST_THREAD_USES_MOVE
 #endif //BOOST_NO_RVALUE_REFERENCES
 #endif // BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS

Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2012-04-09 19:21:16 EDT (Mon, 09 Apr 2012)
@@ -503,7 +503,7 @@
           [ thread-run2 ./sync/mutual_exclusion/locks/reverse_lock/types_pass.cpp : reverse_lock__types_p ]
     ;
 
- explicit tt ;
+ #explicit tt ;
     test-suite tt
     :
           [ thread-run test_ml.cpp ]

Modified: trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp 2012-04-09 19:21:16 EDT (Mon, 09 Apr 2012)
@@ -128,7 +128,7 @@
     p();
     BOOST_TEST(f.get() == 5.0);
   }
- BOOST_TEST(A::n_copies >= 0);
+ BOOST_TEST(A::n_copies > 0);
   BOOST_TEST(A::n_moves > 0);
   BOOST_TEST(test_alloc_base::count == 0);
 

Modified: trunk/libs/thread/test/test_ml.cpp
==============================================================================
--- trunk/libs/thread/test/test_ml.cpp (original)
+++ trunk/libs/thread/test/test_ml.cpp 2012-04-09 19:21:16 EDT (Mon, 09 Apr 2012)
@@ -1,3 +1,6 @@
+#include <boost/config.hpp>
+#ifndef BOOST_NO_RVALUE_REFERENCES
+
 #include <boost/detail/lightweight_test.hpp>
 #include "boost/thread/future.hpp"
 #include "boost/utility/result_of.hpp"
@@ -35,7 +38,7 @@
   std::cout << __FILE__ << ":" << __LINE__ << std::endl;
  typedef typename boost::result_of< F() >::type RetType;
  std::cout << __FILE__ << ":" << __LINE__ << std::endl;
- async_func_pt<RetType>* p= new async_func_pt<RetType> (boost::packaged_task<RetType>(f));
+ async_func_pt<RetType>* p= new async_func_pt<RetType> (boost::packaged_task<RetType>(boost::forward<F>(f)));
  std::cout << __FILE__ << ":" << __LINE__ << std::endl;
  boost::unique_future<RetType> future_result= p->get_future();
  std::cout << __FILE__ << ":" << __LINE__ << std::endl;
@@ -92,7 +95,13 @@
 
 }
 
+#else
+int main()
+{
+ return 0;
+}
 
+#endif
 /*
  *
  "/Users/viboes/clang/llvmCore-3.0-rc1.install/bin/clang++"


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