CernVM-FS
2.12.0
|
#include <mutex.h>
Public Member Functions | |
LockGuard (LockableT *object) | |
Public Member Functions inherited from RAII< LockableT > | |
RAII (LockableT &object) | |
RAII (LockableT *object) | |
~RAII () | |
Additional Inherited Members | |
Protected Member Functions inherited from RAII< LockableT > | |
void | Enter () |
void | Leave () |
This is a simple scoped lock implementation. Every object that provides the methods Lock() and Unlock() should work with it. Classes that will be used with this template should therefore simply inherit from Lockable.
Creating a LockGuard object on the stack will lock the provided object. When the LockGuard runs out of scope it will automatically release the lock. This ensures a clean unlock in a lot of situations!
TODO(jblomer): C++11 replace this by a type alias to RAII