Ticket #7422: 7422_trunk.patch
File 7422_trunk.patch, 4.9 KB (added by , 10 years ago) |
---|
-
boost/thread/pthread/condition_variable.hpp
57 57 58 58 inline void condition_variable::wait(unique_lock<mutex>& m) 59 59 { 60 if(! m.owns_lock()) 61 { 62 boost::throw_exception(condition_error(-1, "boost::condition_variable::wait precondition")); 63 } 60 64 int res=0; 61 65 { 62 thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard;63 66 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 67 thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard; 64 68 detail::interruption_checker check_for_interruption(&internal_mutex,&cond); 65 #else66 boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex);67 #endif68 69 guard.activate(m); 69 70 do { 70 71 res = pthread_cond_wait(&cond,&internal_mutex); 71 72 } while (res == EINTR); 73 #else 74 //boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex); 75 pthread_mutex_t* the_mutex = m.mutex()->native_handle(); 76 do { 77 res = pthread_cond_wait(&cond,the_mutex); 78 } while (res == EINTR); 79 #endif 72 80 } 73 81 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 74 82 this_thread::interruption_point(); … … 83 91 unique_lock<mutex>& m, 84 92 struct timespec const &timeout) 85 93 { 94 #if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED 86 95 if (!m.owns_lock()) 87 96 { 88 97 boost::throw_exception(condition_error(EPERM, "condition_variable do_wait_until: mutex not locked")); 89 98 } 90 99 #endif 91 100 thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard; 92 101 int cond_res; 93 102 { 94 103 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 95 104 detail::interruption_checker check_for_interruption(&internal_mutex,&cond); 105 guard.activate(m); 106 cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); 96 107 #else 97 boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex); 108 //boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex); 109 pthread_mutex_t* the_mutex = m.mutex()->native_handle(); 110 cond_res=pthread_cond_timedwait(&cond,the_mutex,&timeout); 98 111 #endif 99 guard.activate(m);100 cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout);101 112 } 102 113 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 103 114 this_thread::interruption_point(); … … 115 126 116 127 inline void condition_variable::notify_one() BOOST_NOEXCEPT 117 128 { 129 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 118 130 boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); 131 #endif 119 132 BOOST_VERIFY(!pthread_cond_signal(&cond)); 120 133 } 121 134 122 135 inline void condition_variable::notify_all() BOOST_NOEXCEPT 123 136 { 137 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 124 138 boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); 139 #endif 125 140 BOOST_VERIFY(!pthread_cond_broadcast(&cond)); 126 141 } 127 142 -
boost/thread/pthread/condition_variable_fwd.hpp
32 32 class condition_variable 33 33 { 34 34 private: 35 //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 35 36 pthread_mutex_t internal_mutex; 37 //#endif 36 38 pthread_cond_t cond; 37 39 38 40 public: … … 53 55 BOOST_THREAD_NO_COPYABLE(condition_variable) 54 56 condition_variable() 55 57 { 58 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 56 59 int const res=pthread_mutex_init(&internal_mutex,NULL); 57 60 if(res) 58 61 { 59 62 boost::throw_exception(thread_resource_error(res, "boost:: condition_variable constructor failed in pthread_mutex_init")); 60 63 } 64 #endif 61 65 int const res2=pthread_cond_init(&cond,NULL); 62 66 if(res2) 63 67 { 68 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 64 69 BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex)); 70 #endif 65 71 boost::throw_exception(thread_resource_error(res2, "boost:: condition_variable constructor failed in pthread_cond_init")); 66 72 } 67 73 } 68 74 ~condition_variable() 69 75 { 70 76 int ret; 77 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS 71 78 do { 72 79 ret = pthread_mutex_destroy(&internal_mutex); 73 80 } while (ret == EINTR); 74 81 BOOST_ASSERT(!ret); 82 #endif 75 83 do { 76 84 ret = pthread_cond_destroy(&cond); 77 85 } while (ret == EINTR);