X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fmutex.h;fp=source%2Fcore%2Fmutex.h;h=0fe9e82087ff67d4c51d1d7bcde0f2a10d668138;hp=18f9039227e1feb19e7860811e7487a2338dfd9a;hb=1f0843257065789231a9949e0a81b79afd7bbebe;hpb=62a984b46e08740d19cb055f01be3365982f6b9d diff --git a/source/core/mutex.h b/source/core/mutex.h index 18f9039..0fe9e82 100644 --- a/source/core/mutex.h +++ b/source/core/mutex.h @@ -35,21 +35,19 @@ public: }; /** -Locks the mutex for te lifetime of the object. +Locks the mutex for the lifetime of the object. */ class MutexLock { private: Mutex &mutex; + MutexLock(const MutexLock &); public: MutexLock(Mutex &m, bool l = true): mutex(m) { if(l) mutex.lock(); } ~MutexLock() { mutex.unlock(); } void lock() { mutex.lock(); } -private: - MutexLock(const MutexLock &); - MutexLock &operator=(const MutexLock &); }; /** @@ -59,15 +57,16 @@ exists, the mutex will stay locked. template class MutexPtr { +private: + RefPtr mutex; + T *data; + public: MutexPtr(T *d, Mutex &m): mutex(new MutexLock(m)), data(d) { } T &operator*() const { return *data; } T *operator->() const { return data; } - void clear() { mutex=0; data = 0; } -private: - RefPtr mutex; - T *data; + void clear() { mutex = 0; data = 0; } }; }