|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69547 - trunk/boost/thread/pthread
From: anthony_at_[hidden]
Date: 2011-03-04 10:44:54
Author: anthonyw
Date: 2011-03-04 10:44:53 EST (Fri, 04 Mar 2011)
New Revision: 69547
URL: http://svn.boost.org/trac/boost/changeset/69547
Log:
Patch condition variables to ensure that the cond mutex is unlocked before we try and check for interruption
Text files modified:
trunk/boost/thread/pthread/condition_variable.hpp | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
Modified: trunk/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable.hpp 2011-03-04 10:44:53 EST (Fri, 04 Mar 2011)
@@ -53,8 +53,8 @@
detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
guard.activate(m);
res=pthread_cond_wait(&cond,&internal_mutex);
- this_thread::interruption_point();
}
+ this_thread::interruption_point();
if(res)
{
boost::throw_exception(condition_error());
@@ -64,10 +64,13 @@
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;
- detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
- guard.activate(m);
- struct timespec const timeout=detail::get_timespec(wait_until);
- int const cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout);
+ int cond_res;
+ {
+ detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
+ guard.activate(m);
+ struct timespec const timeout=detail::get_timespec(wait_until);
+ int const cond_res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout);
+ }
this_thread::interruption_point();
if(cond_res==ETIMEDOUT)
{
@@ -130,8 +133,8 @@
detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
guard.activate(m);
res=pthread_cond_wait(&cond,&internal_mutex);
- this_thread::interruption_point();
}
+ this_thread::interruption_point();
if(res)
{
boost::throw_exception(condition_error());
@@ -154,8 +157,8 @@
detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
guard.activate(m);
res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout);
- this_thread::interruption_point();
}
+ this_thread::interruption_point();
if(res==ETIMEDOUT)
{
return false;
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