mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Expose Thread::is_main_thread()
This commit is contained in:
parent
8ebf8ae23c
commit
b9bff1fba5
3 changed files with 13 additions and 0 deletions
|
@ -1526,6 +1526,10 @@ void Thread::set_thread_safety_checks_enabled(bool p_enabled) {
|
|||
set_current_thread_safe_for_nodes(!p_enabled);
|
||||
}
|
||||
|
||||
bool Thread::is_main_thread() {
|
||||
return ::Thread::is_main_thread();
|
||||
}
|
||||
|
||||
void Thread::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("start", "callable", "priority"), &Thread::start, DEFVAL(PRIORITY_NORMAL));
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &Thread::get_id);
|
||||
|
@ -1534,6 +1538,7 @@ void Thread::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("wait_to_finish"), &Thread::wait_to_finish);
|
||||
|
||||
ClassDB::bind_static_method("Thread", D_METHOD("set_thread_safety_checks_enabled", "enabled"), &Thread::set_thread_safety_checks_enabled);
|
||||
ClassDB::bind_static_method("Thread", D_METHOD("is_main_thread"), &Thread::is_main_thread);
|
||||
|
||||
BIND_ENUM_CONSTANT(PRIORITY_LOW);
|
||||
BIND_ENUM_CONSTANT(PRIORITY_NORMAL);
|
||||
|
|
|
@ -495,6 +495,7 @@ public:
|
|||
Variant wait_to_finish();
|
||||
|
||||
static void set_thread_safety_checks_enabled(bool p_enabled);
|
||||
static bool is_main_thread();
|
||||
};
|
||||
|
||||
namespace Special {
|
||||
|
|
|
@ -30,6 +30,13 @@
|
|||
To check if a [Thread] is joinable, use [method is_started].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_main_thread" qualifiers="static">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the thread this method was called from is the main thread.
|
||||
[b]Note:[/b] This is a static method and isn't associated with a specific [Thread] object.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_started" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue