Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76084 - trunk/boost/thread/pthread
From: vicente.botet_at_[hidden]
Date: 2011-12-20 16:13:24


Author: viboes
Date: 2011-12-20 16:13:22 EST (Tue, 20 Dec 2011)
New Revision: 76084
URL: http://svn.boost.org/trac/boost/changeset/76084

Log:
Thread: Notify shread_cond when state.exclusive_waiting_blocked=false in shared_mutex::timed_lock to resolve #5502
Text files modified:
   trunk/boost/thread/pthread/shared_mutex.hpp | 26 +++++++++++++-------------
   1 files changed, 13 insertions(+), 13 deletions(-)

Modified: trunk/boost/thread/pthread/shared_mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/shared_mutex.hpp (original)
+++ trunk/boost/thread/pthread/shared_mutex.hpp 2011-12-20 16:13:22 EST (Tue, 20 Dec 2011)
@@ -27,7 +27,7 @@
             bool upgrade;
             bool exclusive_waiting_blocked;
         };
-
+
 
 
         state_data state;
@@ -41,7 +41,7 @@
             exclusive_cond.notify_one();
             shared_cond.notify_all();
         }
-
+
 
     public:
         shared_mutex()
@@ -58,7 +58,7 @@
         {
             boost::this_thread::disable_interruption do_not_disturb;
             boost::mutex::scoped_lock lk(state_change);
-
+
             while(state.exclusive || state.exclusive_waiting_blocked)
             {
                 shared_cond.wait(lk);
@@ -69,7 +69,7 @@
         bool try_lock_shared()
         {
             boost::mutex::scoped_lock lk(state_change);
-
+
             if(state.exclusive || state.exclusive_waiting_blocked)
             {
                 return false;
@@ -85,7 +85,7 @@
         {
             boost::this_thread::disable_interruption do_not_disturb;
             boost::mutex::scoped_lock lk(state_change);
-
+
             while(state.exclusive || state.exclusive_waiting_blocked)
             {
                 if(!shared_cond.timed_wait(lk,timeout))
@@ -107,7 +107,7 @@
         {
             boost::mutex::scoped_lock lk(state_change);
             bool const last_reader=!--state.shared_count;
-
+
             if(last_reader)
             {
                 if(state.upgrade)
@@ -128,7 +128,7 @@
         {
             boost::this_thread::disable_interruption do_not_disturb;
             boost::mutex::scoped_lock lk(state_change);
-
+
             while(state.shared_count || state.exclusive)
             {
                 state.exclusive_waiting_blocked=true;
@@ -150,7 +150,7 @@
                     if(state.shared_count || state.exclusive)
                     {
                         state.exclusive_waiting_blocked=false;
- exclusive_cond.notify_one();
+ release_waiters();
                         return false;
                     }
                     break;
@@ -169,7 +169,7 @@
         bool try_lock()
         {
             boost::mutex::scoped_lock lk(state_change);
-
+
             if(state.shared_count || state.exclusive)
             {
                 return false;
@@ -179,7 +179,7 @@
                 state.exclusive=true;
                 return true;
             }
-
+
         }
 
         void unlock()
@@ -248,7 +248,7 @@
             boost::mutex::scoped_lock lk(state_change);
             state.upgrade=false;
             bool const last_reader=!--state.shared_count;
-
+
             if(last_reader)
             {
                 state.exclusive_waiting_blocked=false;
@@ -278,7 +278,7 @@
             state.exclusive_waiting_blocked=false;
             release_waiters();
         }
-
+
         void unlock_and_lock_shared()
         {
             boost::mutex::scoped_lock lk(state_change);
@@ -287,7 +287,7 @@
             state.exclusive_waiting_blocked=false;
             release_waiters();
         }
-
+
         void unlock_upgrade_and_lock_shared()
         {
             boost::mutex::scoped_lock lk(state_change);


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