Merge pull request #109779 from dsnopek/thread-is-main-thread

Expose `Thread::is_main_thread()`
This commit is contained in:
Thaddeus Crews
2025-09-30 18:35:16 -05:00
3 changed files with 13 additions and 0 deletions

View File

@ -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);

View File

@ -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 {