AutoLock {
public:
 AutoLock() { lock(); }
 ~AutoLock() { unlock(); }
};

F()
{
 try {
  AutoLock autoLock;
 } catch (...) {
  throw;
 }
}