summaryrefslogtreecommitdiff
path: root/core/os/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/os/thread.h')
-rw-r--r--core/os/thread.h40
1 files changed, 12 insertions, 28 deletions
diff --git a/core/os/thread.h b/core/os/thread.h
index 0fb283e224..86442de760 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -35,15 +35,14 @@
#ifdef PLATFORM_THREAD_OVERRIDE
#include "platform_thread.h"
#else
+
#ifndef THREAD_H
#define THREAD_H
+#include "core/templates/safe_refcount.h"
#include "core/typedefs.h"
-#if !defined(NO_THREADS)
-#include "core/templates/safe_refcount.h"
#include <thread>
-#endif
class String;
@@ -64,8 +63,15 @@ public:
Settings() { priority = PRIORITY_NORMAL; }
};
+ struct PlatformFunctions {
+ Error (*set_name)(const String &) = nullptr;
+ void (*set_priority)(Thread::Priority) = nullptr;
+ void (*init)() = nullptr;
+ void (*wrapper)(Thread::Callback, void *) = nullptr;
+ void (*term)() = nullptr;
+ };
+
private:
-#if !defined(NO_THREADS)
friend class Main;
static ID main_thread_id;
@@ -78,20 +84,11 @@ private:
static void callback(Thread *p_self, const Settings &p_settings, Thread::Callback p_callback, void *p_userdata);
- static Error (*set_name_func)(const String &);
- static void (*set_priority_func)(Thread::Priority);
- static void (*init_func)();
- static void (*term_func)();
-#endif
+ static PlatformFunctions platform_functions;
public:
- static void _set_platform_funcs(
- Error (*p_set_name_func)(const String &),
- void (*p_set_priority_func)(Thread::Priority),
- void (*p_init_func)() = nullptr,
- void (*p_term_func)() = nullptr);
+ static void _set_platform_functions(const PlatformFunctions &p_functions);
-#if !defined(NO_THREADS)
_FORCE_INLINE_ ID get_id() const { return id; }
// get the ID of the caller thread
_FORCE_INLINE_ static ID get_caller_id() { return caller_id; }
@@ -107,19 +104,6 @@ public:
Thread();
~Thread();
-#else
- _FORCE_INLINE_ ID get_id() const { return 0; }
- // get the ID of the caller thread
- _FORCE_INLINE_ static ID get_caller_id() { return 0; }
- // get the ID of the main thread
- _FORCE_INLINE_ static ID get_main_id() { return 0; }
-
- static Error set_name(const String &p_name) { return ERR_UNAVAILABLE; }
-
- void start(Thread::Callback p_callback, void *p_user, const Settings &p_settings = Settings()) {}
- bool is_started() const { return false; }
- void wait_to_finish() {}
-#endif
};
#endif // THREAD_H