diff options
Diffstat (limited to 'core/os/mutex.h')
-rw-r--r-- | core/os/mutex.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/core/os/mutex.h b/core/os/mutex.h index a1004965bb..8ec4f573b7 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -31,7 +31,6 @@ #include "error_list.h" - /** * @class Mutex * @author Juan Linietsky @@ -41,18 +40,16 @@ * Lockp( mutex ); */ - class Mutex { protected: - static Mutex* (*create_func)(bool); + static Mutex *(*create_func)(bool); public: + virtual void lock() = 0; ///< Lock the mutex, block if locked by someone else + virtual void unlock() = 0; ///< Unlock the mutex, let other threads continue + virtual Error try_lock() = 0; ///< Attempt to lock the mutex, OK on success, ERROR means it can't lock. - virtual void lock()=0; ///< Lock the mutex, block if locked by someone else - virtual void unlock()=0; ///< Unlock the mutex, let other threads continue - virtual Error try_lock()=0; ///< Attempt to lock the mutex, OK on success, ERROR means it can't lock. - - static Mutex * create(bool p_recursive=true); ///< Create a mutex + static Mutex *create(bool p_recursive = true); ///< Create a mutex virtual ~Mutex(); }; @@ -60,11 +57,15 @@ public: class MutexLock { Mutex *mutex; -public: - - MutexLock(Mutex* p_mutex) { mutex=p_mutex; if (mutex) mutex->lock(); } - ~MutexLock() { if (mutex) mutex->unlock(); } +public: + MutexLock(Mutex *p_mutex) { + mutex = p_mutex; + if (mutex) mutex->lock(); + } + ~MutexLock() { + if (mutex) mutex->unlock(); + } }; #endif |