1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Avoid interaction issues between resource loading threads

This commit is contained in:
Pedro J. Estébanez
2023-03-05 01:09:18 +01:00
parent c80a2b4fe9
commit 8983b20ccd
10 changed files with 461 additions and 392 deletions

View File

@@ -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