$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r86442 - in trunk: boost/thread libs/thread/example
From: vicente.botet_at_[hidden]
Date: 2013-10-26 06:21:27
Author: viboes
Date: 2013-10-26 06:21:27 EDT (Sat, 26 Oct 2013)
New Revision: 86442
URL: http://svn.boost.org/trac/boost/changeset/86442
Log:
Thread: adapt thread_pool and executor to the new nullary_function work.
Text files modified: 
   trunk/boost/thread/executor.hpp           |    25 +++++++++++++++++++------               
   trunk/boost/thread/thread_pool.hpp        |    27 ++++++++++++++++++++++++---             
   trunk/libs/thread/example/executor.cpp    |    20 ++++++++++----------                    
   trunk/libs/thread/example/thread_pool.cpp |    20 ++++++++++----------                    
   4 files changed, 63 insertions(+), 29 deletions(-)
Modified: trunk/boost/thread/executor.hpp
==============================================================================
--- trunk/boost/thread/executor.hpp	Sat Oct 26 06:20:13 2013	(r86441)
+++ trunk/boost/thread/executor.hpp	2013-10-26 06:21:27 EDT (Sat, 26 Oct 2013)	(r86442)
@@ -14,8 +14,7 @@
 
 #include <boost/thread/detail/delete.hpp>
 #include <boost/thread/detail/move.hpp>
-#include <boost/thread/detail/function_wrapper.hpp>
-
+#include <boost/thread/detail/work.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -26,7 +25,7 @@
   {
   public:
     /// type-erasure to store the works to do
-    typedef  detail::function_wrapper work;
+    typedef  thread_detail::work work;
 
     /// executor is not copyable.
     BOOST_THREAD_NO_COPYABLE(executor)
@@ -72,14 +71,28 @@
      * \b Throws: \c sync_queue_is_closed if the thread pool is closed.
      * Whatever exception that can be throw while storing the closure.
      */
-//#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#ifndef BOOST_THREAD_USES_NULLARY_FUNCTION_AS_WORK
     template <typename Closure>
     void submit(Closure const& closure)
     {
       work w ((closure));
       submit(boost::move(w));
     }
-//#endif
+#else
+#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+    template <typename Closure>
+    void submit(Closure & closure)
+    {
+      work w ((closure));
+      submit(boost::move(w));
+    }
+#endif
+    void submit(void (*closure)())
+    {
+      work w ((closure));
+      submit(boost::move(w));
+    }
+#endif
 
     template <typename Closure>
     void submit(BOOST_THREAD_RV_REF(Closure) closure)
@@ -119,7 +132,7 @@
     Executor ex;
   public:
     /// type-erasure to store the works to do
-    typedef  detail::function_wrapper work;
+    typedef  executor::work work;
 
     /// executor is not copyable.
     BOOST_THREAD_NO_COPYABLE(executor_adaptor)
Modified: trunk/boost/thread/thread_pool.hpp
==============================================================================
--- trunk/boost/thread/thread_pool.hpp	Sat Oct 26 06:20:13 2013	(r86441)
+++ trunk/boost/thread/thread_pool.hpp	2013-10-26 06:21:27 EDT (Sat, 26 Oct 2013)	(r86442)
@@ -15,7 +15,8 @@
 #include <boost/thread/detail/move.hpp>
 #include <boost/thread/scoped_thread.hpp>
 #include <boost/thread/sync_queue.hpp>
-#include <boost/thread/detail/function_wrapper.hpp>
+#include <boost/thread/detail/work.hpp>
+
 
 #ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
 #include <boost/function.hpp>
@@ -34,10 +35,11 @@
 namespace boost
 {
 
+
   class thread_pool
   {
     /// type-erasure to store the works to do
-    typedef  detail::function_wrapper work;
+    typedef  thread_detail::work work;
     /// the kind of stored threads are scoped threads to ensure that the threads are joined.
     /// A move aware vector type
     typedef scoped_thread<> thread_t;
@@ -171,13 +173,32 @@
      * \b Throws: \c sync_queue_is_closed if the thread pool is closed.
      * Whatever exception that can be throw while storing the closure.
      */
+#ifndef BOOST_THREAD_USES_NULLARY_FUNCTION_AS_WORK
     template <typename Closure>
-    void submit(Closure const& closure)
+    void submit(Closure const & closure)
     {
       work w ((closure));
       work_queue.push(boost::move(w));
       //work_queue.push(work(closure));
     }
+#else
+    #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+        template <typename Closure>
+        void submit(Closure & closure)
+        {
+          work w ((closure));
+          work_queue.push(boost::move(w));
+          //work_queue.push(work(closure));
+        }
+    #endif
+        void submit(void (*closure)())
+        {
+          work w ((closure));
+          work_queue.push(boost::move(w));
+          //work_queue.push(work(closure));
+        }
+
+#endif
     template <typename Closure>
     void submit(BOOST_THREAD_RV_REF(Closure) closure)
     {
Modified: trunk/libs/thread/example/executor.cpp
==============================================================================
--- trunk/libs/thread/example/executor.cpp	Sat Oct 26 06:20:13 2013	(r86441)
+++ trunk/libs/thread/example/executor.cpp	2013-10-26 06:21:27 EDT (Sat, 26 Oct 2013)	(r86442)
@@ -25,17 +25,17 @@
     << boost::this_thread::get_id()  << " P2" << BOOST_THREAD_END_LOG;
 }
 
-void push(boost::container::deque<boost::detail::function_wrapper> &data_, BOOST_THREAD_RV_REF(boost::detail::function_wrapper) closure)
+void push(boost::container::deque<boost::thread_detail::work> &data_, BOOST_THREAD_RV_REF(boost::thread_detail::work) closure)
 {
   try
   {
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
-    boost::detail::function_wrapper  v;
+    boost::thread_detail::work  v;
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
     //v = boost::move(closure);
-    //v = boost::forward<boost::detail::function_wrapper>(closure);
+    //v = boost::forward<boost::thread_detail::work>(closure);
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
 
@@ -43,7 +43,7 @@
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
 
-    //data_.push_back(boost::forward<boost::detail::function_wrapper>(closure));
+    //data_.push_back(boost::forward<boost::thread_detail::work>(closure));
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
 
@@ -61,14 +61,14 @@
 }
 
 template <typename Closure>
-void submit(boost::container::deque<boost::detail::function_wrapper> &data_, BOOST_THREAD_FWD_REF(Closure) closure)
+void submit(boost::container::deque<boost::thread_detail::work> &data_, BOOST_THREAD_FWD_REF(Closure) closure)
 {
   BOOST_THREAD_LOG
     << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
   //work w =boost::move(closure);
   //work_queue.push(boost::move(w));
-  //push(data_, boost::detail::function_wrapper(boost::forward<Closure>(closure)));
-  boost::detail::function_wrapper  v =boost::forward<Closure>(closure);
+  //push(data_, boost::thread_detail::work(boost::forward<Closure>(closure)));
+  boost::thread_detail::work  v =boost::forward<Closure>(closure);
   BOOST_THREAD_LOG
     << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
   push(data_, boost::move(v));
@@ -85,11 +85,11 @@
   {
     try
     {
-      boost::detail::function_wrapper f(&p1);
+      boost::thread_detail::work f(&p1);
 
-    boost::container::deque<boost::detail::function_wrapper> data_;
+    boost::container::deque<boost::thread_detail::work> data_;
     data_.push_back(boost::move(f));
-    data_.push_back(boost::detail::function_wrapper(&p1));
+    data_.push_back(boost::thread_detail::work(&p1));
     submit(data_, &p1);
     }
     catch (std::exception& ex)
Modified: trunk/libs/thread/example/thread_pool.cpp
==============================================================================
--- trunk/libs/thread/example/thread_pool.cpp	Sat Oct 26 06:20:13 2013	(r86441)
+++ trunk/libs/thread/example/thread_pool.cpp	2013-10-26 06:21:27 EDT (Sat, 26 Oct 2013)	(r86442)
@@ -24,17 +24,17 @@
     << boost::this_thread::get_id()  << " P2" << BOOST_THREAD_END_LOG;
 }
 
-void push(boost::container::deque<boost::detail::function_wrapper> &data_, BOOST_THREAD_RV_REF(boost::detail::function_wrapper) closure)
+void push(boost::container::deque<boost::thread_detail::work> &data_, BOOST_THREAD_RV_REF(boost::thread_detail::work) closure)
 {
   try
   {
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
-    boost::detail::function_wrapper  v;
+    boost::thread_detail::work  v;
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
     //v = boost::move(closure);
-    //v = boost::forward<boost::detail::function_wrapper>(closure);
+    //v = boost::forward<boost::thread_detail::work>(closure);
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
 
@@ -42,7 +42,7 @@
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
 
-    //data_.push_back(boost::forward<boost::detail::function_wrapper>(closure));
+    //data_.push_back(boost::forward<boost::thread_detail::work>(closure));
     BOOST_THREAD_LOG
       << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
 
@@ -60,14 +60,14 @@
 }
 
 template <typename Closure>
-void submit(boost::container::deque<boost::detail::function_wrapper> &data_, BOOST_THREAD_FWD_REF(Closure) closure)
+void submit(boost::container::deque<boost::thread_detail::work> &data_, BOOST_THREAD_FWD_REF(Closure) closure)
 {
   BOOST_THREAD_LOG
     << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
   //work w =boost::move(closure);
   //work_queue.push(boost::move(w));
-  //push(data_, boost::detail::function_wrapper(boost::forward<Closure>(closure)));
-  boost::detail::function_wrapper  v =boost::forward<Closure>(closure);
+  //push(data_, boost::thread_detail::work(boost::forward<Closure>(closure)));
+  boost::thread_detail::work  v =boost::forward<Closure>(closure);
   BOOST_THREAD_LOG
     << boost::this_thread::get_id()  << " <MAIN" << BOOST_THREAD_END_LOG;
   push(data_, boost::move(v));
@@ -84,11 +84,11 @@
   {
     try
     {
-      boost::detail::function_wrapper f(&p1);
+      boost::thread_detail::work f(&p1);
 
-    boost::container::deque<boost::detail::function_wrapper> data_;
+    boost::container::deque<boost::thread_detail::work> data_;
     data_.push_back(boost::move(f));
-    data_.push_back(boost::detail::function_wrapper(&p1));
+    data_.push_back(boost::thread_detail::work(&p1));
     submit(data_, &p1);
     }
     catch (std::exception& ex)