Merge pull request #42263 from Faless/js/servers_no_threads

Ignore thread models when compiling with NO_THREAD
This commit is contained in:
Rémi Verschelde 2020-09-23 11:50:23 +02:00 committed by GitHub
commit 9a463cb1d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -1274,9 +1274,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} }
if (rtm >= 0 && rtm < 3) { if (rtm >= 0 && rtm < 3) {
#ifdef NO_THREADS
rtm = OS::RENDER_THREAD_UNSAFE; // No threads available on this platform.
#else
if (editor) { if (editor) {
rtm = OS::RENDER_THREAD_SAFE; rtm = OS::RENDER_THREAD_SAFE;
} }
#endif
OS::get_singleton()->_render_thread_mode = OS::RenderThreadMode(rtm); OS::get_singleton()->_render_thread_mode = OS::RenderThreadMode(rtm);
} }

View file

@ -1342,6 +1342,10 @@ PhysicsServer2DSW::PhysicsServer2DSW() {
island_count = 0; island_count = 0;
active_objects = 0; active_objects = 0;
collision_pairs = 0; collision_pairs = 0;
#ifdef NO_THREADS
using_threads = false;
#else
using_threads = int(ProjectSettings::get_singleton()->get("physics/2d/thread_model")) == 2; using_threads = int(ProjectSettings::get_singleton()->get("physics/2d/thread_model")) == 2;
#endif
flushing_queries = false; flushing_queries = false;
}; };

View file

@ -317,6 +317,9 @@ public:
template <class T> template <class T>
static PhysicsServer2D *init_server() { static PhysicsServer2D *init_server() {
#ifdef NO_THREADS
return memnew(T); // Always single unsafe when no threads are available.
#else
int tm = GLOBAL_DEF("physics/2d/thread_model", 1); int tm = GLOBAL_DEF("physics/2d/thread_model", 1);
if (tm == 0) { // single unsafe if (tm == 0) { // single unsafe
return memnew(T); return memnew(T);
@ -325,6 +328,7 @@ public:
} else { // multi threaded } else { // multi threaded
return memnew(PhysicsServer2DWrapMT(memnew(T), true)); return memnew(PhysicsServer2DWrapMT(memnew(T), true));
} }
#endif
} }
#undef ServerNameWrapMT #undef ServerNameWrapMT