Jelajahi Sumber

Expose Thread::get_main_id in core bindings

(cherry picked from commit c558263d84e974c95efe4d1e34539d4232e5d26f)
Brian Semrau 3 tahun lalu
induk
melakukan
04846156c3
3 mengubah file dengan 13 tambahan dan 0 penghapusan
  1. 5 0
      core/bind/core_bind.cpp
  2. 1 0
      core/bind/core_bind.h
  3. 7 0
      doc/classes/OS.xml

+ 5 - 0
core/bind/core_bind.cpp

@@ -624,6 +624,10 @@ Thread::ID _OS::get_thread_caller_id() const {
 	return Thread::get_caller_id();
 	return Thread::get_caller_id();
 };
 };
 
 
+Thread::ID _OS::get_main_thread_id() const {
+	return Thread::get_main_id();
+};
+
 bool _OS::has_feature(const String &p_feature) const {
 bool _OS::has_feature(const String &p_feature) const {
 	return OS::get_singleton()->has_feature(p_feature);
 	return OS::get_singleton()->has_feature(p_feature);
 }
 }
@@ -1398,6 +1402,7 @@ void _OS::_bind_methods() {
 
 
 	ClassDB::bind_method(D_METHOD("set_thread_name", "name"), &_OS::set_thread_name);
 	ClassDB::bind_method(D_METHOD("set_thread_name", "name"), &_OS::set_thread_name);
 	ClassDB::bind_method(D_METHOD("get_thread_caller_id"), &_OS::get_thread_caller_id);
 	ClassDB::bind_method(D_METHOD("get_thread_caller_id"), &_OS::get_thread_caller_id);
+	ClassDB::bind_method(D_METHOD("get_main_thread_id"), &_OS::get_main_thread_id);
 
 
 	ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync);
 	ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync);
 	ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled);
 	ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled);

+ 1 - 0
core/bind/core_bind.h

@@ -367,6 +367,7 @@ public:
 
 
 	Error set_thread_name(const String &p_name);
 	Error set_thread_name(const String &p_name);
 	Thread::ID get_thread_caller_id() const;
 	Thread::ID get_thread_caller_id() const;
+	Thread::ID get_main_thread_id() const;
 
 
 	void set_use_vsync(bool p_enable);
 	void set_use_vsync(bool p_enable);
 	bool is_vsync_enabled() const;
 	bool is_vsync_enabled() const;

+ 7 - 0
doc/classes/OS.xml

@@ -271,6 +271,13 @@
 				This can be used to narrow down fully specified locale strings to only the "common" language code, when you don't need the additional information about country code or variants. For example, for a French Canadian user with [code]fr_CA[/code] locale, this would return [code]fr[/code].
 				This can be used to narrow down fully specified locale strings to only the "common" language code, when you don't need the additional information about country code or variants. For example, for a French Canadian user with [code]fr_CA[/code] locale, this would return [code]fr[/code].
 			</description>
 			</description>
 		</method>
 		</method>
+		<method name="get_main_thread_id" qualifiers="const">
+			<return type="int" />
+			<description>
+				Returns the ID of the main thread. See [method get_thread_caller_id].
+				[b]Note:[/b] Thread IDs are not deterministic and may be reused across application restarts.
+			</description>
+		</method>
 		<method name="get_model_name" qualifiers="const">
 		<method name="get_model_name" qualifiers="const">
 			<return type="String" />
 			<return type="String" />
 			<description>
 			<description>