Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7720: exception lock_error while intensive locking/unlocking of mutex
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-11-05 05:23:18
#7720: exception lock_error while intensive locking/unlocking of mutex
--------------------------------+------------------------
Reporter: sergey.stepanov@⦠| Owner: viboes
Type: Bugs | Status: closed
Milestone: Boost 1.54.0 | Component: thread
Version: Boost 1.51.0 | Severity: Regression
Resolution: fixed | Keywords: lock_error
--------------------------------+------------------------
Comment (by ajay.sonawane@â¦):
I modified the test program slightly and I got the lock_Error exceptions
again. I'm using boost 1.54.0. Please let me know if the fix for this
problem is available.
shared_mutex mtx;
unsigned int sharedVariable = 0;
void upgrade()
{
while (true)
{
try
{
upgrade_lock<shared_mutex> lock(mtx);
std::cout << sharedVariable;
}
catch(boost::lock_error& err)
{
std::cout << "Exception in Upgrade: " <<
err.what() << std::endl;
}
}
}
void shared()
{
while (true)
{
try
{
shared_lock<shared_mutex> lock(mtx);
std::cout << sharedVariable;
}
catch(boost::lock_error& err)
{
std::cout << "Exception in Shared: " <<
err.what() << std::endl;
}
}
}
void unique()
{
while (true)
{
try
{
unique_lock<shared_mutex> lock(mtx);
++sharedVariable;;
}
catch(boost::lock_error& err)
{
std::cout << "Exception in Unique: " <<
err.what() << std::endl;
}
}
}
int main()
{
unsigned int numThreads = 1000;
boost::thread_group grp;
{
for (unsigned int i = 0; i < numThreads; i++)
{
if(i % 5 == 0)
grp.create_thread (boost::bind (&unique));
else if(i%3 == 0)
grp.create_thread (boost::bind
(&upgrade));
else
grp.create_thread (boost::bind (&shared));
}
}
grp.join_all ();
return 0;
}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7720#comment:20> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC