In Java:
Lock lock = new ReentrantLock();
try{
lock.lock();
someFunctionLikelyToCauseAnException();
}
catch(e){...}
finally {
lock.unlock();
}
My question is with this above example we know that the lock WILL always get unlocked because finally always executes, but what is the guarantee with C++?
mutex m;
m.lock();
someFunctionLikelyToCauseAnException();
/// ????
How will this work and why?