mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix management of safe-for-nodes flag in ResourceLoader and WorkerThreadPool
This commit is contained in:
parent
46424488ed
commit
30925fcfb0
2 changed files with 8 additions and 3 deletions
|
@ -56,6 +56,8 @@ void WorkerThreadPool::_process_task(Task *p_task) {
|
|||
Task *prev_low_prio_task = nullptr; // In case this is recursively called.
|
||||
|
||||
if (!use_native_low_priority_threads) {
|
||||
// Tasks must start with this unset. They are free to set-and-forget otherwise.
|
||||
set_current_thread_safe_for_nodes(false);
|
||||
pool_thread_index = thread_ids[Thread::get_caller_id()];
|
||||
ThreadData &curr_thread = threads[pool_thread_index];
|
||||
task_mutex.lock();
|
||||
|
@ -179,9 +181,6 @@ void WorkerThreadPool::_process_task(Task *p_task) {
|
|||
if (post) {
|
||||
task_available_semaphore.post();
|
||||
}
|
||||
|
||||
// Engine/user tasks can set-and-forget, so we must be sure it's back to normal by the end of the task.
|
||||
set_current_thread_safe_for_nodes(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,7 +370,9 @@ Error WorkerThreadPool::wait_for_task_completion(TaskID p_task_id) {
|
|||
must_exit = true;
|
||||
} else {
|
||||
// Solve tasks while they are around.
|
||||
bool safe_for_nodes_backup = is_current_thread_safe_for_nodes();
|
||||
_process_task_queue();
|
||||
set_current_thread_safe_for_nodes(safe_for_nodes_backup);
|
||||
continue;
|
||||
}
|
||||
} else if (!use_native_low_priority_threads && task->low_priority) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue