Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84623 - in branches/release: boost/thread boost/thread/pthread libs/thread libs/thread/test libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons
From: vicente.botet_at_[hidden]
Date: 2013-06-03 12:54:00


Author: viboes
Date: 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
New Revision: 84623
URL: http://svn.boost.org/trac/boost/changeset/84623

Log:
Thread: merge 84540 to fiw #8626; fix show stopper in packaged_task<void()>.
Added:
   branches/release/libs/thread/test/test_8596.cpp
      - copied, changed from r84589, /trunk/libs/thread/test/test_8596.cpp
Properties modified:
   branches/release/boost/thread/ (props changed)
   branches/release/libs/thread/ (props changed)
Text files modified:
   branches/release/boost/thread/future.hpp | 16 ------
   branches/release/boost/thread/pthread/mutex.hpp | 90 +++++++++++++++++++++++++++------------
   branches/release/libs/thread/test/Jamfile.v2 | 1
   branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp | 1
   branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp | 1
   branches/release/libs/thread/test/test_8596.cpp | 14 ++++++
   6 files changed, 78 insertions(+), 45 deletions(-)

Modified: branches/release/boost/thread/future.hpp
==============================================================================
--- branches/release/boost/thread/future.hpp (original)
+++ branches/release/boost/thread/future.hpp 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
@@ -2362,18 +2362,12 @@
           task_object(task_object&);
         public:
             F f;
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::forward<F>(f_))
- {}
-#else
             task_object(F const& f_):
                 f(f_)
             {}
             task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::move(f_)) // TODO forward
+ f(boost::move(f_))
             {}
-#endif
 
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
             void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
@@ -2616,18 +2610,12 @@
           task_object(task_object&);
         public:
             F f;
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::forward<F>(f_))
- {}
-#else
             task_object(F const& f_):
                 f(f_)
             {}
             task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::move(f_)) // TODO forward
+ f(boost::move(f_))
             {}
-#endif
 
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
             void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)

Modified: branches/release/boost/thread/pthread/mutex.hpp
==============================================================================
--- branches/release/boost/thread/pthread/mutex.hpp (original)
+++ branches/release/boost/thread/pthread/mutex.hpp 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
@@ -33,10 +33,61 @@
 #endif
 #endif
 
+
 #include <boost/config/abi_prefix.hpp>
 
+#ifndef BOOST_THREAD_HAS_NO_EINTR_BUG
+#define BOOST_THREAD_HAS_EINTR_BUG
+#endif
+
 namespace boost
 {
+ namespace posix {
+#ifdef BOOST_THREAD_HAS_EINTR_BUG
+ BOOST_FORCEINLINE int pthread_mutex_destroy(pthread_mutex_t* m)
+ {
+ int ret;
+ do
+ {
+ ret = ::pthread_mutex_destroy(m);
+ } while (ret == EINTR);
+ return ret;
+ }
+ BOOST_FORCEINLINE int pthread_mutex_lock(pthread_mutex_t* m)
+ {
+ int ret;
+ do
+ {
+ ret = ::pthread_mutex_lock(m);
+ } while (ret == EINTR);
+ return ret;
+ }
+ BOOST_FORCEINLINE int pthread_mutex_unlock(pthread_mutex_t* m)
+ {
+ int ret;
+ do
+ {
+ ret = ::pthread_mutex_unlock(m);
+ } while (ret == EINTR);
+ return ret;
+ }
+#else
+ BOOST_FORCEINLINE int pthread_mutex_destroy(pthread_mutex_t* m)
+ {
+ return ::pthread_mutex_destroy(m);
+ }
+ BOOST_FORCEINLINE int pthread_mutex_lock(pthread_mutex_t* m)
+ {
+ return ::pthread_mutex_lock(m);
+ }
+ BOOST_FORCEINLINE int pthread_mutex_unlock(pthread_mutex_t* m)
+ {
+ return ::pthread_mutex_unlock(m);
+ }
+
+#endif
+
+ }
     class mutex
     {
     private:
@@ -54,20 +105,12 @@
         }
         ~mutex()
         {
- int ret;
- do
- {
- ret = pthread_mutex_destroy(&m);
- } while (ret == EINTR);
+ BOOST_VERIFY(!posix::pthread_mutex_destroy(&m));
         }
 
         void lock()
         {
- int res;
- do
- {
- res = pthread_mutex_lock(&m);
- } while (res == EINTR);
+ int res = posix::pthread_mutex_lock(&m);
             if (res)
             {
                 boost::throw_exception(lock_error(res,"boost: mutex lock failed in pthread_mutex_lock"));
@@ -76,14 +119,10 @@
 
         void unlock()
         {
- int res;
- do
- {
- res = pthread_mutex_unlock(&m);
- } while (res == EINTR);
+ int res = posix::pthread_mutex_unlock(&m);
             if (res)
             {
- boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_lock"));
+ boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_unlock"));
             }
         }
 
@@ -138,7 +177,8 @@
             int const res2=pthread_cond_init(&cond,NULL);
             if(res2)
             {
- BOOST_VERIFY(!pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!posix::pthread_mutex_destroy(&m));
+ //BOOST_VERIFY(!pthread_mutex_destroy(&m));
                 boost::throw_exception(thread_resource_error(res2, "boost:: timed_mutex constructor failed in pthread_cond_init"));
             }
             is_locked=false;
@@ -146,7 +186,7 @@
         }
         ~timed_mutex()
         {
- BOOST_VERIFY(!pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!posix::pthread_mutex_destroy(&m));
 #ifndef BOOST_PTHREAD_HAS_TIMEDLOCK
             BOOST_VERIFY(!pthread_cond_destroy(&cond));
 #endif
@@ -166,11 +206,7 @@
 #ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
         void lock()
         {
- int res;
- do
- {
- res = pthread_mutex_lock(&m);
- } while (res == EINTR);
+ int res = posix::pthread_mutex_lock(&m);
             if (res)
             {
                 boost::throw_exception(lock_error(res,"boost: mutex lock failed in pthread_mutex_lock"));
@@ -179,14 +215,10 @@
 
         void unlock()
         {
- int res;
- do
- {
- res = pthread_mutex_unlock(&m);
- } while (res == EINTR);
+ int res = posix::pthread_mutex_unlock(&m);
             if (res)
             {
- boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_lock"));
+ boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_unlock"));
             }
         }
 

Modified: branches/release/libs/thread/test/Jamfile.v2
==============================================================================
--- branches/release/libs/thread/test/Jamfile.v2 (original)
+++ branches/release/libs/thread/test/Jamfile.v2 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
@@ -759,6 +759,7 @@
           #[ thread-run ../example/perf_condition_variable.cpp ]
           #[ thread-run ../example/perf_shared_mutex.cpp ]
           #[ thread-run ../example/std_async_test.cpp ]
+ [ thread-run test_8596.cpp ]
     ;
 
 }

Modified: branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp (original)
+++ branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
@@ -25,7 +25,6 @@
 int main()
 {
   boost::mutex m;
- m.lock();
   boost::unique_lock<boost::mutex> lk(m, boost::defer_lock);
   BOOST_TEST(lk.mutex() == &m);
   BOOST_TEST(lk.owns_lock() == false);

Modified: branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp (original)
+++ branches/release/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
@@ -19,7 +19,6 @@
 int main()
 {
   boost::mutex m;
- m.lock();
 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
   auto
 #else

Copied: branches/release/libs/thread/test/test_8596.cpp (from r84589, /trunk/libs/thread/test/test_8596.cpp)
==============================================================================
--- /trunk/libs/thread/test/test_8596.cpp (original)
+++ branches/release/libs/thread/test/test_8596.cpp 2013-06-03 12:53:59 EDT (Mon, 03 Jun 2013)
@@ -26,6 +26,12 @@
   return result;
 }
 
+struct MyFunc
+{
+ void operator()()const {}
+};
+
+
 int main()
 {
   boost::packaged_task<int()>* p(schedule(f));
@@ -34,5 +40,13 @@
   boost::future<int> fut = p->get_future();
   std::cout << "The answer to the ultimate question: " << fut.get() << std::endl;
 
+ {
+ //boost::function<void()> f;
+ MyFunc mf;
+
+ //boost::packaged_task<void()> t1(f); // error 1
+ boost::packaged_task<void()> t2(mf); // error 2
+ }
+
   return 0;
 }


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