diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-12 14:10:03 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-12 14:10:03 +0200 |
commit | 8dd48a98e20f093a3dc32d1269fe45de9f1593aa (patch) | |
tree | bed8cf96df4905dda04face4a71104c3be2e34ca | |
parent | e0bbb83e7c1ba0b7d0f8aaf1926c7e0d9d12901c (diff) | |
parent | 123ba9d464584b6681dcc1958552025878349e1f (diff) | |
download | redot-engine-8dd48a98e20f093a3dc32d1269fe45de9f1593aa.tar.gz |
Merge pull request #76999 from RandomShaper/fix_wtp_exit
`WorkerThreadPool`: Handle exit signal in the tentative scheduling done during waits
-rw-r--r-- | core/object/worker_thread_pool.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp index 3dca6b73a6..c188872baf 100644 --- a/core/object/worker_thread_pool.cpp +++ b/core/object/worker_thread_pool.cpp @@ -258,15 +258,20 @@ void WorkerThreadPool::wait_for_task_completion(TaskID p_task_id) { if (index) { // We are an actual process thread, we must not be blocked so continue processing stuff if available. + bool must_exit = false; while (true) { if (task->done_semaphore.try_wait()) { // If done, exit break; } - if (task_available_semaphore.try_wait()) { - // Solve tasks while they are around. - _process_task_queue(); - continue; + if (!must_exit && task_available_semaphore.try_wait()) { + if (exit_threads) { + must_exit = true; + } else { + // Solve tasks while they are around. + _process_task_queue(); + continue; + } } OS::get_singleton()->delay_usec(1); // Microsleep, this could be converted to waiting for multiple objects in supported platforms for a bit more performance. } |