diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 15 | ||||
-rw-r--r-- | core/bind/core_bind.h | 2 | ||||
-rw-r--r-- | core/os/thread.cpp | 5 | ||||
-rw-r--r-- | core/os/thread.h | 4 |
4 files changed, 25 insertions, 1 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 30c90bd71c..743ae19a93 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1941,6 +1941,9 @@ Error _Thread::start(Object *p_instance,const StringName& p_method,const Variant return ERR_CANT_CREATE; } + if (name != "") + thread->set_name(name); + return OK; } @@ -1972,12 +1975,24 @@ Variant _Thread::wait_to_finish() { return r; } +Error _Thread::set_name(const String &p_name) { + + name = p_name; + + if (thread) { + return thread->set_name(p_name); + }; + + return OK; +}; + void _Thread::_bind_methods() { ObjectTypeDB::bind_method(_MD("start:Error","instance","method","userdata","priority"),&_Thread::start,DEFVAL(Variant()),DEFVAL(PRIORITY_NORMAL)); ObjectTypeDB::bind_method(_MD("get_id"),&_Thread::get_id); ObjectTypeDB::bind_method(_MD("is_active"),&_Thread::is_active); ObjectTypeDB::bind_method(_MD("wait_to_finish:Variant"),&_Thread::wait_to_finish); + ObjectTypeDB::bind_method(_MD("set_name:Error", "name"),&_Thread::set_name); BIND_CONSTANT( PRIORITY_LOW ); BIND_CONSTANT( PRIORITY_NORMAL ); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 24ea810767..172f33dac5 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -508,6 +508,7 @@ protected: Object *target_instance; StringName target_method; Thread *thread; + String name; static void _bind_methods(); static void _start_func(void *ud); public: @@ -523,6 +524,7 @@ public: String get_id() const; bool is_active() const; Variant wait_to_finish(); + Error set_name(const String& p_name); _Thread(); ~_Thread(); diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 96b0f561ca..53db62c176 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -58,6 +58,11 @@ void Thread::wait_to_finish(Thread *p_thread) { } +Error Thread::set_name(const String &p_name) { + + return ERR_UNAVAILABLE; +}; + Thread::Thread() { } diff --git a/core/os/thread.h b/core/os/thread.h index 590fee1fc6..e3d00b0397 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -35,6 +35,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ +#include "ustring.h" typedef void (*ThreadCreateCallback)(void *p_userdata); @@ -71,7 +72,8 @@ protected: Thread(); public: - + + virtual Error set_name(const String& p_name); virtual ID get_ID() const=0; |