template<typename Lockable>
class JSYNCHRONIZATION::JBasicScopedLock< Lockable >
Scoped lock.
The main purpose of this class is to provide an exception-safe locking facility. The lock on the mutex is acquired during construction, while the unlock is performed in the destructor.
Es: Case 1, without scoped lock: using namespace JSYNCHRONIZATION; JMutex mutex;
{ mutex.lock(); throwing_function(variable_to_protect); // <- this shall throw mutex.lock(); // <- this call is never // executed -> deadlock }
Case 2, with scoped lock: using namespace JSYNCHRONIZATION; JMutex mutex;
{ JScopedLock(mutex); throwing_function(variable_to_protect); // <- this shall throw } // the lock is released here automatically
Definition at line 47 of file JMutex.hh.