diff --git a/core/os/thread_pool.cpp b/core/os/thread_pool.cpp index 7f2bbcede..653601e20 100644 --- a/core/os/thread_pool.cpp +++ b/core/os/thread_pool.cpp @@ -40,7 +40,8 @@ bool ThreadPool::get_use_threads() const { return _use_threads; } void ThreadPool::set_use_threads(const bool value) { - _use_threads = value; + // Will be applied later in update, so current jobs can be finished first + _use_threads_new = value; _dirty = true; } @@ -295,6 +296,8 @@ void ThreadPool::register_core_settings() { } } + _use_threads_new = _use_threads; + _dirty = true; apply_settings(); @@ -329,6 +332,8 @@ void ThreadPool::apply_settings() { _threads.resize(0); + _use_threads = _use_threads_new; + if (_use_threads) { _threads.resize(_thread_count); diff --git a/core/os/thread_pool.h b/core/os/thread_pool.h index ed9abbcdb..79e9a6dad 100644 --- a/core/os/thread_pool.h +++ b/core/os/thread_pool.h @@ -101,6 +101,7 @@ private: bool _dirty; bool _use_threads; + bool _use_threads_new; int _thread_count; int _thread_fallback_count; float _max_work_per_frame_percent;