As per title, how to try_lock on a boost::unique_lock ?
I’ve this code:
void mySafeFunct()
{
if(myMutex.try_lock() == false)
{
return -1;
}
// mutex ownership is automatically acquired
// do stuff safely
myMutex.unlock();
}
Now I’d like to use a unique_lock (which is also a scoped mutex) instead of the plain boost::mutex. I want this to avoid all the unlock() calls from the function body.
1 Answer