summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript.h')
-rw-r--r--modules/gdscript/gdscript.h44
1 files changed, 19 insertions, 25 deletions
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 31811bba47..7b0e2136ed 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -117,29 +117,28 @@ class GDScript : public Script {
HashMap<GDScriptFunction *, LambdaInfo> lambda_info;
- // List is used here because a ptr to elements are stored, so the memory locations need to be stable
- struct UpdatableFuncPtr {
- List<GDScriptFunction **> ptrs;
- Mutex mutex;
- bool initialized : 1;
- bool transferred : 1;
- uint32_t rc = 1;
- UpdatableFuncPtr() :
- initialized(false), transferred(false) {}
- };
- struct UpdatableFuncPtrElement {
- List<GDScriptFunction **>::Element *element = nullptr;
- UpdatableFuncPtr *func_ptr = nullptr;
+public:
+ class UpdatableFuncPtr {
+ friend class GDScript;
+
+ GDScriptFunction *ptr = nullptr;
+ GDScript *script = nullptr;
+ List<UpdatableFuncPtr *>::Element *list_element = nullptr;
+
+ public:
+ GDScriptFunction *operator->() const { return ptr; }
+ operator GDScriptFunction *() const { return ptr; }
+
+ UpdatableFuncPtr(GDScriptFunction *p_function);
+ ~UpdatableFuncPtr();
};
- static UpdatableFuncPtr func_ptrs_to_update_main_thread;
- static thread_local UpdatableFuncPtr *func_ptrs_to_update_thread_local;
+
+private:
+ // List is used here because a ptr to elements are stored, so the memory locations need to be stable
List<UpdatableFuncPtr *> func_ptrs_to_update;
Mutex func_ptrs_to_update_mutex;
- UpdatableFuncPtrElement _add_func_ptr_to_update(GDScriptFunction **p_func_ptr_ptr);
- static void _remove_func_ptr_to_update(const UpdatableFuncPtrElement &p_func_ptr_element);
-
- static void _fixup_thread_function_bookkeeping();
+ void _recurse_replace_function_ptrs(const HashMap<GDScriptFunction *, GDScriptFunction *> &p_replacements) const;
#ifdef TOOLS_ENABLED
// For static data storage during hot-reloading.
@@ -541,7 +540,7 @@ public:
virtual void get_string_delimiters(List<String> *p_delimiters) const override;
virtual bool is_using_templates() override;
virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const override;
- virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) override;
+ virtual Vector<ScriptTemplate> get_built_in_templates(const StringName &p_object) override;
virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override;
virtual Script *create_script() const override;
#ifndef DISABLE_DEPRECATED
@@ -562,11 +561,6 @@ public:
virtual void add_named_global_constant(const StringName &p_name, const Variant &p_value) override;
virtual void remove_named_global_constant(const StringName &p_name) override;
- /* MULTITHREAD FUNCTIONS */
-
- virtual void thread_enter() override;
- virtual void thread_exit() override;
-
/* DEBUGGER FUNCTIONS */
virtual String debug_get_error() const override;