1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-23 15:16:17 +00:00

Merge pull request #98385 from RandomShaper/thread_yield

Rationalize busy waits
This commit is contained in:
Rémi Verschelde
2024-12-20 23:56:39 +01:00
7 changed files with 30 additions and 22 deletions

View File

@@ -2881,10 +2881,7 @@ void RichTextLabel::_thread_end() {
void RichTextLabel::_stop_thread() {
if (threaded) {
stop_thread.store(true);
if (task != WorkerThreadPool::INVALID_TASK_ID) {
WorkerThreadPool::get_singleton()->wait_for_task_completion(task);
task = WorkerThreadPool::INVALID_TASK_ID;
}
wait_until_finished();
}
}
@@ -2908,6 +2905,13 @@ bool RichTextLabel::is_updating() const {
return updating.load() || validating.load();
}
void RichTextLabel::wait_until_finished() {
if (task != WorkerThreadPool::INVALID_TASK_ID) {
WorkerThreadPool::get_singleton()->wait_for_task_completion(task);
task = WorkerThreadPool::INVALID_TASK_ID;
}
}
void RichTextLabel::set_threaded(bool p_threaded) {
if (threaded != p_threaded) {
_stop_thread();