Index: boost/thread/pthread/condition_variable.hpp =================================================================== --- boost/thread/pthread/condition_variable.hpp (revision 81999) +++ boost/thread/pthread/condition_variable.hpp (working copy) @@ -57,18 +57,26 @@ inline void condition_variable::wait(unique_lock& m) { + if(! m.owns_lock()) + { + boost::throw_exception(condition_error(-1, "boost::condition_variable::wait precondition")); + } int res=0; { - thread_cv_detail::lock_on_exit > guard; #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS + thread_cv_detail::lock_on_exit > 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 +91,24 @@ unique_lock& 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 > guard; int cond_res; { #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS detail::interruption_checker check_for_interruption(&internal_mutex,&cond); + guard.activate(m); + cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); #else - boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex); + //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 - guard.activate(m); - cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); } #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS this_thread::interruption_point(); @@ -115,13 +126,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)); } Index: boost/thread/pthread/condition_variable_fwd.hpp =================================================================== --- boost/thread/pthread/condition_variable_fwd.hpp (revision 81999) +++ boost/thread/pthread/condition_variable_fwd.hpp (working copy) @@ -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);