
14 Dec
2006
14 Dec
'06
2:58 p.m.
Ovanes Markarian wrote:
Hi!
you could define a scope where to lock ;) Just like this:
boost::mutex a_mutex; ... { { boost::mutex::scoped_lock lock(a_mutex); //lock cout<<"bla"; }//end of scope => unlock
//much of code where cout dont has to be locked ... }
Or: foo() { boost::mutex::scoped_lock lk(a_mutex); cout << "bla" ; lk.unlock(); .... some other stuff unlocked lk.lock(); // lock again ..... } The lock is (conditionally) unlocked however when you leave the scope. Roland