I have a ScopedLock class which can help to release lock automatically when running out of scope. However, the problem is: Sometimes team members write invalid
ScopedLock
replace it with macro
#define CON2(x,y) x##y #define CON(x,y) CON2(x,y) #define LOCK(x) ScopedLock CON(unique_,__COUNTER__)(mutex)
usage
{ LOCK(mutex); //do stuff }
This macro will generate unique names for locks, allowing lockeng of other mutexes in inner scopes