~interruption_checker() { if(thread_info && thread_info->interrupt_enabled) { lock_guard<mutex> guard(thread_info->data_mutex); thread_info->current_cond=NULL; check_for_interruption(); } }
explicit interruption_checker(pthread_cond_t* cond): thread_info(detail::get_current_thread_data()) { if(thread_info && thread_info->interrupt_enabled) { lock_guard<mutex> guard(thread_info->data_mutex); check_for_interruption(); thread_info->current_cond=cond; } }
inline bool condition_variable::timed_wait(unique_lock<mutex>& m,boost::system_time const& wait_until) { detail::interruption_checker check_for_interruption(&cond); struct timespec const timeout=detail::get_timespec(wait_until); int const cond_res=pthread_cond_timedwait(&cond,m.mutex()->native_handle(),&timeout); if(cond_res==ETIMEDOUT) { return false; } BOOST_ASSERT(!cond_res); return true; }
inline void condition_variable::wait(unique_lock<mutex>& m) { int res=0; { thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard; detail::interruption_checker check_for_interruption(&internal_mutex,&cond); guard.activate(m); res=pthread_cond_wait(&cond,&internal_mutex); } this_thread::interruption_point(); if(res) { boost::throw_exception(condition_error()); } }
void wait(lock_type& m) { int res=0; { thread_cv_detail::lock_on_exit<lock_type> guard; detail::interruption_checker check_for_interruption(&internal_mutex,&cond); guard.activate(m); res=pthread_cond_wait(&cond,&internal_mutex); } this_thread::interruption_point(); if(res) { boost::throw_exception(condition_error()); } }
void wait(lock_type& m) { int res=0; { detail::interruption_checker check_for_interruption(&cond); { boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); m.unlock(); res=pthread_cond_wait(&cond,&internal_mutex); } m.lock(); } if(res) { boost::throw_exception(condition_error()); } }
inline bool condition_variable::timed_wait(unique_lock<mutex>& m,boost::system_time const& wait_until) { thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard; int cond_res; { detail::interruption_checker check_for_interruption(&internal_mutex,&cond); guard.activate(m); struct timespec const timeout=detail::get_timespec(wait_until); cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); } this_thread::interruption_point(); if(cond_res==ETIMEDOUT) { return false; } if(cond_res) { boost::throw_exception(condition_error()); } return true; }
bool timed_wait(lock_type& m,boost::system_time const& wait_until) { struct timespec const timeout=detail::get_timespec(wait_until); int res=0; { thread_cv_detail::lock_on_exit<lock_type> guard; detail::interruption_checker check_for_interruption(&internal_mutex,&cond); guard.activate(m); res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); } this_thread::interruption_point(); if(res==ETIMEDOUT) { return false; } if(res) { boost::throw_exception(condition_error()); } return true; }
bool timed_wait(lock_type& m,boost::system_time const& wait_until) { struct timespec const timeout=detail::get_timespec(wait_until); int res=0; { detail::interruption_checker check_for_interruption(&cond); { boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); m.unlock(); res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); } m.lock(); } if(res==ETIMEDOUT) { return false; } if(res) { boost::throw_exception(condition_error()); } return true; }
inline void condition_variable::wait(unique_lock<mutex>& m) { detail::interruption_checker check_for_interruption(&cond); BOOST_VERIFY(!pthread_cond_wait(&cond,m.mutex()->native_handle())); }