[Core] Allow locking/unlocking of MutexLock

This commit is contained in:
A Thousand Ships
2024-06-29 13:01:01 +02:00
parent e53dc80f2f
commit 723f5500f4
4 changed files with 59 additions and 26 deletions

View File

@ -103,6 +103,16 @@ public:
~MutexLock() {
mutex.unlock();
}
_ALWAYS_INLINE_ void temp_relock() const {
mutex.lock();
}
_ALWAYS_INLINE_ void temp_unlock() const {
mutex.unlock();
}
// TODO: Implement a `try_temp_relock` if needed (will also need a dummy method below).
};
#else // No threads.
@ -119,6 +129,16 @@ public:
void unlock() const {}
};
template <int Tag>
class MutexLock<SafeBinaryMutex<Tag>> {
public:
MutexLock(const SafeBinaryMutex<Tag> &p_mutex) {}
~MutexLock() {}
void temp_relock() const {}
void temp_unlock() const {}
};
#endif // THREADS_ENABLED
#endif // SAFE_BINARY_MUTEX_H