
2 Nov
2010
2 Nov
'10
7:33 p.m.
Hello. I have a question about mutexes: Scenario 1: (OK) int main() { boost::mutex io_mutex; io_mutex.lock(); // thread will be blocked now boost::mutex::scoped_lock lock(io_mutex); cout << "Test" // this statement is not executed: OK } So far no problem, but if I use recursive_mutex instead... Scenario 2: (NOT OK) int main() { boost::recursive_mutex io_mutex; io_mutex.lock(); // thread will NOT be blocked ??? boost::recursive_mutex::scoped_lock lock(io_mutex); cout << "Test" // this statement is executed ??? } no blocking occurs?? I tried with unique_lock instead of scoped_lock but still no blocking Why not? I don't understand. How does one lock a recursive_mutex then? thank you Chris