|
Boost Users : |
Subject: [Boost-users] [thread]Is shared_mutex recursive with respect to shared locks?
From: Ken Savela (ksavela_at_[hidden])
Date: 2008-12-29 10:25:40
In other words, should the following code result in a deadlock?
#include <iostream>
#include <boost/thread.hpp>
int main(int argc, char* argv[])
{
boost::shared_mutex smx;
boost::upgrade_lock<boost::shared_mutex> lock_one(smx);
std::cout << "Locked once." << std::endl;
std::cout.flush();
boost::upgrade_lock<boost::shared_mutex> lock_two(smx);
std::cout << "Locked again." << std::endl;
std::cout.flush();
boost::upgrade_to_unique_lock<boost::shared_mutex> lock_three(lock_two);
std::cout << "Write lock." << std::endl;
return 0;
}
This example illustrates the problem I'm having in my app -- I have a
situation where a single thread may end up performing more than a single
shared lock. When it does so, it hangs on the nested upgrade_lock. Is this
the expected behavior?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net