You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
WorkerThreadPool (plus friends): Overhaul unlock allowance zones
This fixes a rare but possible deadlock, maybe due to undefined behavior. The new implementation is safer, at the cost of some added boilerplate.
(cherry picked from commit f4d76853b9)
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#define CONDITION_VARIABLE_H
|
||||
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/os/safe_binary_mutex.h"
|
||||
|
||||
#ifdef THREADS_ENABLED
|
||||
|
||||
@@ -56,7 +57,12 @@ class ConditionVariable {
|
||||
public:
|
||||
template <typename BinaryMutexT>
|
||||
_ALWAYS_INLINE_ void wait(const MutexLock<BinaryMutexT> &p_lock) const {
|
||||
condition.wait(const_cast<THREADING_NAMESPACE::unique_lock<THREADING_NAMESPACE::mutex> &>(p_lock.lock));
|
||||
condition.wait(const_cast<THREADING_NAMESPACE::unique_lock<THREADING_NAMESPACE::mutex> &>(p_lock._get_lock()));
|
||||
}
|
||||
|
||||
template <int Tag>
|
||||
_ALWAYS_INLINE_ void wait(const MutexLock<SafeBinaryMutex<Tag>> &p_lock) const {
|
||||
condition.wait(const_cast<THREADING_NAMESPACE::unique_lock<THREADING_NAMESPACE::mutex> &>(p_lock.mutex._get_lock()));
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ void notify_one() const {
|
||||
|
||||
Reference in New Issue
Block a user