1 #ifndef GAUDIKERNEL_LOCKEDHANDLE 2 #define GAUDIKERNEL_LOCKEDHANDLE 1 27 template <
class T,
class MutexType = std::mutex>
35 void set( T* ptr, MutexType* mut ) {
55 operator T&() {
return *
m_ptr; }
73 operator const T&()
const {
return *
m_ptr; }
92 operator bool()
const {
return m_ptr; }
Guard operator->()
Aquire and release the lock before and after the object is accessed.
Guard(const Guard &a)=delete
Guard(T *ptr, MutexType &mutex)
ConstGuard(const T *ptr, MutexType &mutex)
const T & operator *() const
const T * operator->() const
void set(T *ptr, MutexType *mut)
Provides automatic lock/unlock access to a class upon deref of ptr.
ConstGuard(const ConstGuard &a)=delete
LockedHandle(T *ptr, MutexType *mut)
LockedHandle(T *ptr, MutexType &mut)
ConstGuard(ConstGuard &&a)
Guard operator *()
Aquire and release the lock before and after the object is accessed.
ConstGuard operator->() const
Aquire and release the lock before and after the const object is accessed.
void setMutex(MutexType *mut)