----- Original Message -----
Sent: Tuesday, September 14, 2010 11:21
AM
Subject: [Threads-devel] Request Help On
boost::lock_error
Hello
I am trying to model a usecase where a member function reads in a value
& now has to modify the value by calling another function. The code which
I have written using upgrade_locks fails at run time. I have gone through the
documentation & have cleared the code as best as I could to arrive at a
condensed usecase. I have also attached some sample erroneous outputs & a
backtrace of the thread in question. Can someone please have a
look?
[...]
int
boostThreadLocksTest::firstFunction(boostThreadLocksTest
*pBoostThreadLocksTest)
{
pBoostThreadLocksTest->myLock.lock();
pBoostThreadLocksTest->secondFunction(pBoostThreadLocksTest);
pBoostThreadLocksTest->myLock.unlock();
return(0);
}
int boostThreadLocksTest::secondFunction(boostThreadLocksTest
*pBoostThreadLocksTest)
{
boost::upgrade_to_unique_lock<boost::shared_mutex>
localUniqueLock(pBoostThreadLocksTest->myLock);
return(0);
}
***********************************************
Hi,
Unfortunately boost::shared_mutex is not
recursive :(.
Why do you use a shared mutex if you lock it
exclusively in firstFunction and secondFunction? upgrade_to_unique_lock has a
sens only if the mutext has been lock_shared. Shouldn't you user
lock_shared()/unlock_shared() in firstFunction?
Best,
Vicente