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=c0c26829630b9dee55bdabf885fd76a6a87ca4f5;hp=50a64e55aaa0a87a1a6d114960ed5cd3416e5527;hb=d5dd704b2576f878809e87dbb8ff8591b9bdbce4;hpb=47a232c3c19e718a30281d3ada8acc1b6212ea8c;ds=sidebyside diff --git a/source/core/mutex.h b/source/core/mutex.h index 50a64e5..c0c2682 100644 --- a/source/core/mutex.h +++ b/source/core/mutex.h @@ -28,7 +28,7 @@ public: int unlock() { return pthread_mutex_unlock(&mutex); } ~Mutex() { pthread_mutex_destroy(&mutex); } #else - Mutex() { mutex=CreateMutex(0, false, 0); } + Mutex() { mutex = CreateMutex(0, false, 0); } int lock() { return WaitForSingleObject(mutex, INFINITE)==WAIT_OBJECT_0; } int trylock() { return WaitForSingleObject(mutex, 0)==WAIT_OBJECT_0; } int unlock() { return !ReleaseMutex(mutex); } @@ -45,7 +45,7 @@ private: Mutex &mutex; public: - MutexLock(Mutex &m, bool l=true): mutex(m) { if(l) mutex.lock(); } + MutexLock(Mutex &m, bool l = true): mutex(m) { if(l) mutex.lock(); } ~MutexLock() { mutex.unlock(); } int lock() { return mutex.lock(); } @@ -66,7 +66,7 @@ public: T &operator*() const { return *data; } T *operator->() const { return data; } - void clear() { mutex=0; data=0; } + void clear() { mutex=0; data = 0; } private: RefPtr mutex; T *data; @@ -80,7 +80,7 @@ public: MutexPtr(const MutexPtr &p): RefCount(p), mutex(p.mutex), data(p.data) { } T &operator*() const { return *data; } T *operator->() const { return data; } - void clear() { decref(); data=0; } + void clear() { decref(); data = 0; } ~MutexPtr() { decref(); } protected: Mutex &mutex;