diff options
author | myaaaaaaaaa <103326468+myaaaaaaaaa@users.noreply.github.com> | 2023-02-22 16:49:48 -0500 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-27 16:43:47 +0200 |
commit | 6ed9e03449097cea58189df53cd53aaf061b3f59 (patch) | |
tree | ce72305936edf142e549ebc7dc69e308dcca042e /core/os | |
parent | db3fadc560bae67b882fabf3022f8d72a3ab3561 (diff) |
Fix data races in startup/teardown
(cherry picked from commit d337ed1c64de89ed410cfe208ea162e4cd4ae503)
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; |