diff options
| author | David Snopek <dsnopek@gmail.com> | 2024-09-17 14:53:39 -0500 |
|---|---|---|
| committer | David Snopek <dsnopek@gmail.com> | 2024-10-17 09:06:27 -0500 |
| commit | 91833c852e47a83ed01deb26213b9d3184de736d (patch) | |
| tree | f5d03c2f87ef31f617d2f458b0b4c05bbead7632 /src/classes | |
| parent | a98d41f62bdb8b7aa903e8e37c1faa48fe8fdae8 (diff) | |
| download | redot-cpp-91833c852e47a83ed01deb26213b9d3184de736d.tar.gz | |
Avoid `thread_local` on MacOS to prevent issues with hot reload
Diffstat (limited to 'src/classes')
| -rw-r--r-- | src/classes/wrapped.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp index d397d46..3eb17ca 100644 --- a/src/classes/wrapped.cpp +++ b/src/classes/wrapped.cpp @@ -39,11 +39,16 @@ #include <godot_cpp/core/class_db.hpp> namespace godot { -thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr; -thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr; + +#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL +std::recursive_mutex Wrapped::_constructing_mutex; +#endif + +_GODOT_CPP_THREAD_LOCAL const StringName *Wrapped::_constructing_extension_class_name = nullptr; +_GODOT_CPP_THREAD_LOCAL const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr; #ifdef HOT_RELOAD_ENABLED -thread_local GDExtensionObjectPtr Wrapped::_constructing_recreate_owner = nullptr; +_GODOT_CPP_THREAD_LOCAL GDExtensionObjectPtr Wrapped::_constructing_recreate_owner = nullptr; #endif const StringName *Wrapped::_get_extension_class_name() { @@ -51,6 +56,10 @@ const StringName *Wrapped::_get_extension_class_name() { } void Wrapped::_postinitialize() { +#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL + Wrapped::_constructing_mutex.unlock(); +#endif + // Only send NOTIFICATION_POSTINITIALIZE for extension classes. if (_is_extension_class()) { _notificationv(Object::NOTIFICATION_POSTINITIALIZE); |
