Add THREADS_ENABLED macro in order to compile Godot to run on the main thread

This commit is contained in:
Adam Scott
2023-12-01 13:39:09 -05:00
parent 107f2961cc
commit bd70b8e1f6
33 changed files with 447 additions and 72 deletions

View File

@ -33,19 +33,22 @@
#include "thread.h"
#ifdef THREADS_ENABLED
#include "core/object/script_language.h"
#include "core/templates/safe_refcount.h"
Thread::PlatformFunctions Thread::platform_functions;
SafeNumeric<uint64_t> Thread::id_counter(1); // The first value after .increment() is 2, hence by default the main thread ID should be 1.
thread_local Thread::ID Thread::caller_id = Thread::UNASSIGNED_ID;
#endif
Thread::PlatformFunctions Thread::platform_functions;
void Thread::_set_platform_functions(const PlatformFunctions &p_functions) {
platform_functions = p_functions;
}
#ifdef THREADS_ENABLED
void Thread::callback(ID p_caller_id, const Settings &p_settings, Callback p_callback, void *p_userdata) {
Thread::caller_id = p_caller_id;
if (platform_functions.set_priority) {
@ -107,4 +110,6 @@ Thread::~Thread() {
}
}
#endif // THREADS_ENABLED
#endif // PLATFORM_THREAD_OVERRIDE