summaryrefslogtreecommitdiff
path: root/core/os/mutex.h
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-03-08 00:06:57 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-03-08 01:53:13 +0100
commitd96179be75ecc344bf71f2d1ffa60f6847d6425e (patch)
tree75cd239f67cd3c39867ce74b4c6f371421896d8c /core/os/mutex.h
parent8cb6d5daa4e41443d658265379b6079d8a087b41 (diff)
Fix mutex when building with no threads.
Diffstat (limited to 'core/os/mutex.h')
-rw-r--r--core/os/mutex.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 8d7b378d60..9033f0cb06 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -71,9 +71,22 @@ public:
}
};
+using Mutex = MutexImpl<std::recursive_mutex>; // Recursive, for general use
+using BinaryMutex = MutexImpl<std::mutex>; // Non-recursive, handle with care
+
+extern template class MutexImpl<std::recursive_mutex>;
+extern template class MutexImpl<std::mutex>;
+extern template class MutexLock<MutexImpl<std::recursive_mutex> >;
+extern template class MutexLock<MutexImpl<std::mutex> >;
+
#else
-template <class StdMutexType>
+class FakeMutex {
+
+ FakeMutex(){};
+};
+
+template <class MutexT>
class MutexImpl {
public:
_ALWAYS_INLINE_ void lock() const {}
@@ -87,14 +100,9 @@ public:
explicit MutexLock(const MutexT &p_mutex) {}
};
-#endif // !NO_THREADS
-
-using Mutex = MutexImpl<std::recursive_mutex>; // Recursive, for general use
-using BinaryMutex = MutexImpl<std::mutex>; // Non-recursive, handle with care
+using Mutex = MutexImpl<FakeMutex>;
+using BinaryMutex = MutexImpl<FakeMutex>; // Non-recursive, handle with care
-extern template class MutexImpl<std::recursive_mutex>;
-extern template class MutexImpl<std::mutex>;
-extern template class MutexLock<MutexImpl<std::recursive_mutex> >;
-extern template class MutexLock<MutexImpl<std::mutex> >;
+#endif // !NO_THREADS
#endif