there are two solutions:
A:
lock()
try{
action()
}catch(...)
{
unlock()
throw;
}
unlock()
B:
{
LockObject lockObject;
action();
}
LockObject's constuctor will call lock(),its de-construtor will call unlock().
So what's the better solution or is there any other better solution?
ps: in linux c++, it doesn't support keywords finally. So I have to make decision for this issue.