Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Revert "Fix a deadlock in WorkerThreadPool"

HP van Braamb52750533800
diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp
index 79a3ba144ee..5b97eb5f621 100644
--- a/core/object/message_queue.cpp
+++ b/core/object/message_queue.cpp
@@ -31,7 +31,6 @@
#include "message_queue.h"
#include "core/config/project_settings.h"
-#include "main/main.h"
#include <cstdio>
@@ -223,10 +222,6 @@ void CallQueue::_call_function(const Callable &p_callable, const Variant *p_args
}
Error CallQueue::flush() {
- if (!Main::is_iterating()) {
- return ERR_BUSY;
- }
-
LOCK_MUTEX;
if (pages.is_empty()) {
diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp
index 8bb9d61f68b..f5574c47a05 100644
--- a/core/object/worker_thread_pool.cpp
+++ b/core/object/worker_thread_pool.cpp
@@ -452,18 +452,7 @@ Error WorkerThreadPool::wait_for_task_completion(TaskID p_task_id) {
}
} else {
task_mutex.unlock();
- if (Thread::is_main_thread()) {
- // If we are the main thread we can't block the messagequeue
- while (!task->done_semaphore.try_wait()) {
- if (MessageQueue::get_singleton()) {
- MessageQueue::get_singleton()->flush();
- }
-
- OS::get_singleton()->delay_usec(100);
- }
- } else {
- task->done_semaphore.wait();
- }
+ task->done_semaphore.wait();
task_mutex.lock();
task->waiting_user--;
if (task->waiting_pool == 0 && task->waiting_user == 0) {
@@ -750,18 +739,7 @@ void WorkerThreadPool::wait_for_group_task_completion(GroupID p_group) {
if (this == singleton) {
_unlock_unlockable_mutexes();
}
- if (Thread::is_main_thread()) {
- // If we are the main thread we can't block the messagequeue
- while (!group->done_semaphore.try_wait()) {
- if (MessageQueue::get_singleton()) {
- MessageQueue::get_singleton()->flush();
- }
-
- OS::get_singleton()->delay_usec(100);
- }
- } else {
- group->done_semaphore.wait();
- }
+ group->done_semaphore.wait();
if (this == singleton) {
_lock_unlockable_mutexes();
}
diff --git a/main/main.cpp b/main/main.cpp
index 2a97b93c912..b8a7c6c3565 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -875,7 +875,6 @@ Error Main::test_setup() {
ClassDB::set_current_api(ClassDB::API_NONE);
- iterating++;
_start_success = true;
return OK;
@@ -884,7 +883,6 @@ Error Main::test_setup() {
// The order is the same as in `Main::cleanup()`.
void Main::test_cleanup() {
ERR_FAIL_COND(!_start_success);
- iterating--;
// Printing in the usual way can become problematic during/after cleanup.
CoreGlobals::print_ready = false;