]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/mutex.h
Make sure all files have the correct header
[libs/core.git] / source / core / mutex.h
index 8088a2839dbd21a15b8567f3768e850d5c5bb583..50a64e55aaa0a87a1a6d114960ed5cd3416e5527 100644 (file)
@@ -4,6 +4,7 @@ This file is part of libmspcore
 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
+
 #ifndef MSP_CORE_MUTEX_H_
 #define MSP_CORE_MUTEX_H_
 
@@ -14,6 +15,11 @@ namespace Msp {
 
 class Mutex
 {
+       friend class Semaphore;
+
+private:
+       MutexHandle mutex;
+
 public:
 #ifndef WIN32
        Mutex()       { pthread_mutex_init(&mutex, 0); }
@@ -28,10 +34,6 @@ public:
        int unlock()  { return !ReleaseMutex(mutex); }
        ~Mutex()      { CloseHandle(mutex); }
 #endif
-private:
-       MutexHandle mutex;
-
-       friend class Semaphore;
 };
 
 /**
@@ -39,14 +41,15 @@ Locks the mutex for te lifetime of the object.
 */
 class MutexLock
 {
+private:
+       Mutex &mutex;
+
 public:
        MutexLock(Mutex &m, bool l=true): mutex(m) { if(l) mutex.lock(); }
        ~MutexLock() { mutex.unlock(); }
 
        int lock() { return mutex.lock(); }
 private:
-       Mutex &mutex;
-
        MutexLock(const MutexLock &);
        MutexLock &operator=(const MutexLock &);
 };