diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-03-06 19:57:38 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-03-06 19:57:38 +0100 |
commit | e80ab423efa874fdddab691ba0bb63fa828d50f3 (patch) | |
tree | 4189bf9ca10d970180d3d0973252c107200ad198 /core/os | |
parent | 3695fe5a573678c6491a6a33f19f9329d3256a48 (diff) | |
parent | d337ed1c64de89ed410cfe208ea162e4cd4ae503 (diff) | |
download | redot-engine-e80ab423efa874fdddab691ba0bb63fa828d50f3.tar.gz |
Merge pull request #73793 from myaaaaaaaaa/init-race
Fix some race conditions that happen during initialization
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/thread.cpp | 6 | ||||
-rw-r--r-- | core/os/thread.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 9d16392b2a..92865576f3 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -50,8 +50,8 @@ void Thread::_set_platform_functions(const PlatformFunctions &p_functions) { platform_functions = p_functions; } -void Thread::callback(Thread *p_self, const Settings &p_settings, Callback p_callback, void *p_userdata) { - Thread::caller_id = _thread_id_hash(p_self->thread.get_id()); +void Thread::callback(ID p_caller_id, const Settings &p_settings, Callback p_callback, void *p_userdata) { + Thread::caller_id = p_caller_id; if (platform_functions.set_priority) { platform_functions.set_priority(p_settings.priority); } @@ -79,7 +79,7 @@ void Thread::start(Thread::Callback p_callback, void *p_user, const Settings &p_ std::thread empty_thread; thread.swap(empty_thread); } - std::thread new_thread(&Thread::callback, this, p_settings, p_callback, p_user); + std::thread new_thread(&Thread::callback, _thread_id_hash(thread.get_id()), p_settings, p_callback, p_user); thread.swap(new_thread); id = _thread_id_hash(thread.get_id()); } diff --git a/core/os/thread.h b/core/os/thread.h index 3d4c48a760..6eb21fba65 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -82,7 +82,7 @@ private: static thread_local ID caller_id; std::thread thread; - static void callback(Thread *p_self, const Settings &p_settings, Thread::Callback p_callback, void *p_userdata); + static void callback(ID p_caller_id, const Settings &p_settings, Thread::Callback p_callback, void *p_userdata); static PlatformFunctions platform_functions; |