mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #76999 from RandomShaper/fix_wtp_exit
`WorkerThreadPool`: Handle exit signal in the tentative scheduling done during waits
This commit is contained in:
commit
8dd48a98e2
1 changed files with 9 additions and 4 deletions
|
@ -258,15 +258,20 @@ void WorkerThreadPool::wait_for_task_completion(TaskID p_task_id) {
|
||||||
|
|
||||||
if (index) {
|
if (index) {
|
||||||
// We are an actual process thread, we must not be blocked so continue processing stuff if available.
|
// We are an actual process thread, we must not be blocked so continue processing stuff if available.
|
||||||
|
bool must_exit = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (task->done_semaphore.try_wait()) {
|
if (task->done_semaphore.try_wait()) {
|
||||||
// If done, exit
|
// If done, exit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (task_available_semaphore.try_wait()) {
|
if (!must_exit && task_available_semaphore.try_wait()) {
|
||||||
// Solve tasks while they are around.
|
if (exit_threads) {
|
||||||
_process_task_queue();
|
must_exit = true;
|
||||||
continue;
|
} 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.
|
OS::get_singleton()->delay_usec(1); // Microsleep, this could be converted to waiting for multiple objects in supported platforms for a bit more performance.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue