mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Fix mutex when building with no threads.
This commit is contained in:
@@ -40,7 +40,11 @@ void _global_unlock() {
|
|||||||
_global_mutex.unlock();
|
_global_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_THREADS
|
||||||
|
|
||||||
template class MutexImpl<std::recursive_mutex>;
|
template class MutexImpl<std::recursive_mutex>;
|
||||||
template class MutexImpl<std::mutex>;
|
template class MutexImpl<std::mutex>;
|
||||||
template class MutexLock<MutexImpl<std::recursive_mutex> >;
|
template class MutexLock<MutexImpl<std::recursive_mutex> >;
|
||||||
template class MutexLock<MutexImpl<std::mutex> >;
|
template class MutexLock<MutexImpl<std::mutex> >;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -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
|
#else
|
||||||
|
|
||||||
template <class StdMutexType>
|
class FakeMutex {
|
||||||
|
|
||||||
|
FakeMutex(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class MutexT>
|
||||||
class MutexImpl {
|
class MutexImpl {
|
||||||
public:
|
public:
|
||||||
_ALWAYS_INLINE_ void lock() const {}
|
_ALWAYS_INLINE_ void lock() const {}
|
||||||
@@ -87,14 +100,9 @@ public:
|
|||||||
explicit MutexLock(const MutexT &p_mutex) {}
|
explicit MutexLock(const MutexT &p_mutex) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using Mutex = MutexImpl<FakeMutex>;
|
||||||
|
using BinaryMutex = MutexImpl<FakeMutex>; // Non-recursive, handle with care
|
||||||
|
|
||||||
#endif // !NO_THREADS
|
#endif // !NO_THREADS
|
||||||
|
|
||||||
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> >;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user