6 ms·
mutex.lock(); doStuff(); /*throws an exception, mutex is never unlocked*/ mutex.unlock(); ScopedLock lock(mutex); doStuff(); /*mutex unlocked by destru
by DerKommissar 13y ago
mutex.lock();
doStuff(); /*throws an exception, mutex is never unlocked*/
mutex.unlock();
ScopedLock lock(mutex);
doStuff(); /*mutex unlocked by destructor in all cases*/
It guarantees that resources are freed no matter how the scope exits.