diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/os/thread.h | 7 | ||||
-rw-r--r-- | core/reference.h | 4 | ||||
-rw-r--r-- | core/script_language.cpp | 16 | ||||
-rw-r--r-- | core/script_language.h | 10 |
4 files changed, 31 insertions, 6 deletions
diff --git a/core/os/thread.h b/core/os/thread.h index 7349b83dbc..5f0ec707f2 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -39,6 +39,8 @@ typedef void (*ThreadCreateCallback)(void *p_userdata); + + class Thread { public: @@ -65,15 +67,14 @@ protected: static void (*wait_to_finish_func)(Thread*); static Error (*set_name_func)(const String&); - friend class Main; + friend class Main; - static ID _main_thread_id; + static ID _main_thread_id; Thread(); public: - virtual ID get_ID() const=0; static Error set_name(const String &p_name); diff --git a/core/reference.h b/core/reference.h index 60a256dc99..89e9627b77 100644 --- a/core/reference.h +++ b/core/reference.h @@ -341,7 +341,7 @@ struct PtrToArg< Ref<T> > { _FORCE_INLINE_ static void encode(Ref<T> p_val,const void* p_ptr) { - *((T**)p_ptr)=p_val.ptr(); + *(Ref<Reference>*)p_ptr=p_val; } }; @@ -371,7 +371,7 @@ struct PtrToArg< RefPtr > { _FORCE_INLINE_ static void encode(RefPtr p_val,const void* p_ptr) { Ref<Reference> r = p_val; - *((Reference**)p_ptr)=r.ptr(); + *(Ref<Reference>*)p_ptr=r; } }; diff --git a/core/script_language.cpp b/core/script_language.cpp index 68a694398a..466242d39d 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -102,6 +102,22 @@ bool ScriptServer::is_reload_scripts_on_save_enabled() { return reload_scripts_on_save; } +void ScriptServer::thread_enter() { + + for(int i=0;i<_language_count;i++) { + _languages[i]->thread_enter(); + } +} + +void ScriptServer::thread_exit() { + + for(int i=0;i<_language_count;i++) { + _languages[i]->thread_exit(); + } + +} + + void ScriptInstance::get_property_state(List<Pair<StringName, Variant> > &state) { List<PropertyInfo> pinfo; diff --git a/core/script_language.h b/core/script_language.h index bde4d619ab..de725d8d08 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -59,6 +59,9 @@ public: static void set_reload_scripts_on_save(bool p_enable); static bool is_reload_scripts_on_save_enabled(); + static void thread_enter(); + static void thread_exit(); + static void init_languages(); }; @@ -128,7 +131,6 @@ public: virtual void call_multilevel_reversed(const StringName& p_method,const Variant** p_args,int p_argcount); virtual void notification(int p_notification)=0; - //this is used by script languages that keep a reference counter of their own //you can make make Ref<> not die when it reaches zero, so deleting the reference //depends entirely from the script @@ -183,6 +185,12 @@ public: virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0; virtual void add_global_constant(const StringName& p_variable,const Variant& p_value)=0; + /* MULTITHREAD FUNCTIONS */ + + //some VMs need to be notified of thread creation/exiting to allocate a stack + virtual void thread_enter() {} + virtual void thread_exit() {} + /* DEBUGGER FUNCTIONS */ virtual String debug_get_error() const=0; |