Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82159 - in branches/release: boost/thread boost/thread/pthread libs/thread libs/thread/build libs/thread/doc libs/thread/example libs/thread/test
From: vicente.botet_at_[hidden]
Date: 2012-12-21 17:15:15


Author: viboes
Date: 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
New Revision: 82159
URL: http://svn.boost.org/trac/boost/changeset/82159

Log:
Thread: merge from trunk condition_variables no-it + doc
Added:
   branches/release/libs/thread/example/perf_condition_variable.cpp
      - copied unchanged from r82152, /trunk/libs/thread/example/perf_condition_variable.cpp
Properties modified:
   branches/release/boost/thread/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/thread/doc/ (props changed)
Text files modified:
   branches/release/boost/thread/pthread/condition_variable.hpp | 33 +++++++++++++++++++++++++--------
   branches/release/boost/thread/pthread/condition_variable_fwd.hpp | 8 ++++++++
   branches/release/libs/thread/build/Jamfile.v2 | 1 +
   branches/release/libs/thread/doc/condition_variables.qbk | 8 ++++----
   branches/release/libs/thread/doc/thread_ref.qbk | 7 +++----
   branches/release/libs/thread/test/Jamfile.v2 | 16 +++++++++-------
   6 files changed, 50 insertions(+), 23 deletions(-)

Modified: branches/release/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- branches/release/boost/thread/pthread/condition_variable.hpp (original)
+++ branches/release/boost/thread/pthread/condition_variable.hpp 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
@@ -57,18 +57,28 @@
 
     inline void condition_variable::wait(unique_lock<mutex>& m)
     {
+#if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
+ if(! m.owns_lock())
+ {
+ boost::throw_exception(condition_error(-1, "boost::condition_variable::wait precondition"));
+ }
+#endif
         int res=0;
         {
- thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard;
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
+ thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard;
             detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
-#else
- boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex);
-#endif
             guard.activate(m);
             do {
               res = pthread_cond_wait(&cond,&internal_mutex);
             } while (res == EINTR);
+#else
+ //boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex);
+ pthread_mutex_t* the_mutex = m.mutex()->native_handle();
+ do {
+ res = pthread_cond_wait(&cond,the_mutex);
+ } while (res == EINTR);
+#endif
         }
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
         this_thread::interruption_point();
@@ -83,21 +93,24 @@
                 unique_lock<mutex>& m,
                 struct timespec const &timeout)
     {
+#if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
         if (!m.owns_lock())
         {
             boost::throw_exception(condition_error(EPERM, "condition_variable do_wait_until: mutex not locked"));
         }
-
+#endif
         thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard;
         int cond_res;
         {
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
             detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
-#else
- boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex);
-#endif
             guard.activate(m);
             cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout);
+#else
+ //boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex);
+ pthread_mutex_t* the_mutex = m.mutex()->native_handle();
+ cond_res=pthread_cond_timedwait(&cond,the_mutex,&timeout);
+#endif
         }
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
         this_thread::interruption_point();
@@ -115,13 +128,17 @@
 
     inline void condition_variable::notify_one() BOOST_NOEXCEPT
     {
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
         boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
+#endif
         BOOST_VERIFY(!pthread_cond_signal(&cond));
     }
 
     inline void condition_variable::notify_all() BOOST_NOEXCEPT
     {
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
         boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
+#endif
         BOOST_VERIFY(!pthread_cond_broadcast(&cond));
     }
 

Modified: branches/release/boost/thread/pthread/condition_variable_fwd.hpp
==============================================================================
--- branches/release/boost/thread/pthread/condition_variable_fwd.hpp (original)
+++ branches/release/boost/thread/pthread/condition_variable_fwd.hpp 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
@@ -32,7 +32,9 @@
     class condition_variable
     {
     private:
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
         pthread_mutex_t internal_mutex;
+#endif
         pthread_cond_t cond;
 
     public:
@@ -53,25 +55,31 @@
       BOOST_THREAD_NO_COPYABLE(condition_variable)
         condition_variable()
         {
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
             int const res=pthread_mutex_init(&internal_mutex,NULL);
             if(res)
             {
                 boost::throw_exception(thread_resource_error(res, "boost:: condition_variable constructor failed in pthread_mutex_init"));
             }
+#endif
             int const res2=pthread_cond_init(&cond,NULL);
             if(res2)
             {
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
                 BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex));
+#endif
                 boost::throw_exception(thread_resource_error(res2, "boost:: condition_variable constructor failed in pthread_cond_init"));
             }
         }
         ~condition_variable()
         {
             int ret;
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
             do {
               ret = pthread_mutex_destroy(&internal_mutex);
             } while (ret == EINTR);
             BOOST_ASSERT(!ret);
+#endif
             do {
               ret = pthread_cond_destroy(&cond);
             } while (ret == EINTR);

Modified: branches/release/libs/thread/build/Jamfile.v2
==============================================================================
--- branches/release/libs/thread/build/Jamfile.v2 (original)
+++ branches/release/libs/thread/build/Jamfile.v2 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
@@ -115,6 +115,7 @@
       <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
       <define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
       #<define>BOOST_SYSTEM_NO_DEPRECATED
+ #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
       <library>/boost/system//boost_system
     ;
 

Modified: branches/release/libs/thread/doc/condition_variables.qbk
==============================================================================
--- branches/release/libs/thread/doc/condition_variables.qbk (original)
+++ branches/release/libs/thread/doc/condition_variables.qbk 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
@@ -346,8 +346,8 @@
 invoking `lock.lock()` before the call to `wait` returns. The lock is also
 reacquired by invoking `lock.lock()` if the function exits with an exception.]]
 
-[[Returns:] [`cv_status::no_timeout` if the call is returning because the time specified by
-`abs_time` was reached, `cv_status::timeout` otherwise.]]
+[[Returns:] [`cv_status::timeout` if the call is returning because the time specified by
+`abs_time` was reached, `cv_status::no_timeout` otherwise.]]
 
 [[Postcondition:] [`lock` is locked by the current thread.]]
 
@@ -378,8 +378,8 @@
 `wait` returns. The lock is also reacquired by invoking `lock.lock()` if the
 function exits with an exception.]]
 
-[[Returns:] [`cv_status::no_timeout ` if the call is returning because the time period specified
-by `rel_time` has elapsed, `cv_status::timeout ` otherwise.]]
+[[Returns:] [`cv_status::timeout ` if the call is returning because the time period specified
+by `rel_time` has elapsed, `cv_status::no_timeout ` otherwise.]]
 
 [[Postcondition:] [`lock` is locked by the current thread.]]
 

Modified: branches/release/libs/thread/doc/thread_ref.qbk
==============================================================================
--- branches/release/libs/thread/doc/thread_ref.qbk (original)
+++ branches/release/libs/thread/doc/thread_ref.qbk 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
@@ -1501,8 +1501,7 @@
 
 [variablelist
 
-[[Effects:] [Suspends the current thread until the time period
-specified by `rel_time` has elapsed or the time point specified by
+[[Effects:] [Suspends the current thread until the time point specified by
 `abs_time` has been reached.]]
 
 [[Throws:] [Nothing if Clock satisfies the TrivialClock requirements and operations of Duration
@@ -1526,8 +1525,8 @@
 
 [variablelist
 
-[[Effects:] [Suspends the current thread until the time point specified by
-`abs_time` has been reached.]]
+[[Effects:] [Suspends the current thread until the duration specified by
+by `rel_time` has elapsed.]]
 
 [[Throws:] [Nothing if operations of chrono::duration<Rep, Period> do not throw exceptions. __thread_interrupted__ if the current thread of execution is interrupted.]]
 

Modified: branches/release/libs/thread/test/Jamfile.v2
==============================================================================
--- branches/release/libs/thread/test/Jamfile.v2 (original)
+++ branches/release/libs/thread/test/Jamfile.v2 2012-12-21 17:15:14 EST (Fri, 21 Dec 2012)
@@ -126,9 +126,9 @@
     [ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
         : : :
       : $(name)_lib ]
- [ run $(sources) ../build//boost_thread : : :
- <define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
- : $(name)_noit ]
+ #[ run $(sources) ../build//boost_thread : : :
+ # <define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
+ # : $(name)_noit ]
     ;
 }
 
@@ -313,7 +313,7 @@
           [ thread-run2-noit ./sync/futures/future/move_ctor_pass.cpp : future__move_ctor_p ]
           [ thread-run2-noit ./sync/futures/future/move_assign_pass.cpp : future__move_asign_p ]
           [ thread-run2-noit ./sync/futures/future/share_pass.cpp : future__share_p ]
- [ thread-run2-noit ./sync/futures/future/then_pass.cpp : future__then_p ]
+ #[ thread-run2-noit ./sync/futures/future/then_pass.cpp : future__then_p ]
     ;
 
     #explicit ts_shared_future ;
@@ -617,9 +617,9 @@
           #[ thread-run ../example/vhh_shared_monitor.cpp ]
           #[ thread-run ../example/vhh_shared_mutex.cpp ]
           [ thread-run ../example/make_future.cpp ]
- [ thread-run ../example/future_then.cpp ]
- [ thread-run2-noit ../example/synchronized_value.cpp : ex_synchronized_value ]
- [ thread-run2-noit ../example/synchronized_person.cpp : ex_synchronized_person ]
+ #[ thread-run ../example/future_then.cpp ]
+ #[ thread-run2-noit ../example/synchronized_value.cpp : ex_synchronized_value ]
+ #[ thread-run2-noit ../example/synchronized_person.cpp : ex_synchronized_person ]
           [ thread-run2-noit ../example/thread_guard.cpp : ex_thread_guard ]
           [ thread-run2-noit ../example/scoped_thread.cpp : ex_scoped_thread ]
           [ thread-run2-noit ../example/strict_lock.cpp : ex_strict_lock ]
@@ -662,6 +662,7 @@
     explicit ts_ ;
     test-suite ts_
     :
+
           #[ thread-run2-noit ./sync/futures/future/then_pass.cpp : future__then_p ]
           #[ thread-run ../example/test_so.cpp ]
           #[ thread-run ../example/test_so2.cpp ]
@@ -670,6 +671,7 @@
           #[ thread-run test_7665.cpp ]
           #[ thread-run test_7666.cpp ]
           #[ thread-run ../example/unwrap.cpp ]
+ [ thread-run ../example/perf_condition_variable.cpp ]
     ;
 
 }


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