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.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 3e7aa81bc1..a968fd7029 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -72,13 +72,28 @@ public:
template <typename MutexT>
class MutexLock {
- friend class ConditionVariable;
-
- THREADING_NAMESPACE::unique_lock<typename MutexT::StdMutexType> lock;
+ mutable THREADING_NAMESPACE::unique_lock<typename MutexT::StdMutexType> lock;
public:
explicit MutexLock(const MutexT &p_mutex) :
lock(p_mutex.mutex) {}
+
+ // Clarification: all the funny syntax is needed so this function exists only for binary mutexes.
+ template <typename T = MutexT>
+ _ALWAYS_INLINE_ THREADING_NAMESPACE::unique_lock<THREADING_NAMESPACE::mutex> &_get_lock(
+ typename std::enable_if<std::is_same<T, THREADING_NAMESPACE::mutex>::value> * = nullptr) const {
+ return lock;
+ }
+
+ _ALWAYS_INLINE_ void temp_relock() const {
+ lock.lock();
+ }
+
+ _ALWAYS_INLINE_ void temp_unlock() const {
+ lock.unlock();
+ }
+
+ // TODO: Implement a `try_temp_relock` if needed (will also need a dummy method below).
};
using Mutex = MutexImpl<THREADING_NAMESPACE::recursive_mutex>; // Recursive, for general use
@@ -104,6 +119,9 @@ template <typename MutexT>
class MutexLock {
public:
MutexLock(const MutexT &p_mutex) {}
+
+ void temp_relock() const {}
+ void temp_unlock() const {}
};
using Mutex = MutexImpl;