5 #ifndef CVMFS_UTIL_MUTEX_H_
6 #define CVMFS_UTIL_MUTEX_H_
12 #ifdef CVMFS_NAMESPACE_GUARD
13 namespace CVMFS_NAMESPACE_GUARD {
41 template <
typename T, RAII_Polymorphism::T P = RAII_Polymorphism::None>
44 inline explicit RAII(T &
object) : ref_(object) { Enter(); }
45 inline explicit RAII(T *
object) : ref_(*object) { Enter(); }
49 inline void Enter() { ref_.Lock(); }
50 inline void Leave() { ref_.Unlock(); }
68 template <
typename LockableT>
71 inline explicit LockGuard(LockableT *
object) :
RAII<LockableT>(object) {}
83 inline void RAII<pthread_rwlock_t,
85 pthread_rwlock_rdlock(&ref_);
88 inline void RAII<pthread_rwlock_t,
90 pthread_rwlock_unlock(&ref_);
93 inline void RAII<pthread_rwlock_t,
95 pthread_rwlock_wrlock(&ref_);
98 inline void RAII<pthread_rwlock_t,
100 pthread_rwlock_unlock(&ref_);
105 #ifdef CVMFS_NAMESPACE_GUARD
109 #endif // CVMFS_UTIL_MUTEX_H_
RAII< pthread_rwlock_t, RAII_Polymorphism::ReadLock > ReadLockGuard
LockGuard(LockableT *object)
RAII< pthread_rwlock_t, RAII_Polymorphism::WriteLock > WriteLockGuard
RAII< pthread_mutex_t > MutexLockGuard