summaryrefslogtreecommitdiffstats
path: root/core/os/mutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/os/mutex.h')
-rw-r--r--core/os/mutex.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 90cc1632e8..cee0f8af74 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -119,8 +119,25 @@ class MutexLock {
public:
_ALWAYS_INLINE_ explicit MutexLock(const MutexT &p_mutex) :
+ lock(p_mutex.mutex){};
+};
+
+// This specialization is needed so manual locking and MutexLock can be used
+// at the same time on a SafeBinaryMutex.
+template <int Tag>
+class MutexLock<SafeBinaryMutex<Tag>> {
+ friend class ConditionVariable;
+
+ std::unique_lock<std::mutex> lock;
+
+public:
+ _ALWAYS_INLINE_ explicit MutexLock(const SafeBinaryMutex<Tag> &p_mutex) :
lock(p_mutex.mutex) {
- }
+ SafeBinaryMutex<Tag>::count++;
+ };
+ _ALWAYS_INLINE_ ~MutexLock() {
+ SafeBinaryMutex<Tag>::count--;
+ };
};
using Mutex = MutexImpl<std::recursive_mutex>; // Recursive, for general use