Merge pull request #78612 from RandomShaper/mq_flush_ref

Refactor CallQueue flushing for clarity
This commit is contained in:
Yuri Sizov 2023-07-14 18:49:08 +02:00
commit acd34153ba
2 changed files with 59 additions and 53 deletions

View File

@ -222,11 +222,7 @@ void CallQueue::_call_function(const Callable &p_callable, const Variant *p_args
}
}
Error CallQueue::flush() {
LOCK_MUTEX;
// Thread overrides are not meant to be flushed, but appended to the main one.
if (this == MessageQueue::thread_singleton) {
Error CallQueue::_transfer_messages_to_main_queue() {
if (pages.size() == 0) {
return OK;
}
@ -276,8 +272,16 @@ Error CallQueue::flush() {
pages_used = 1;
return OK;
}
Error CallQueue::flush() {
// Thread overrides are not meant to be flushed, but appended to the main one.
if (unlikely(this == MessageQueue::thread_singleton)) {
return _transfer_messages_to_main_queue();
}
LOCK_MUTEX;
if (pages.size() == 0) {
// Never allocated
UNLOCK_MUTEX;

View File

@ -98,6 +98,8 @@ private:
}
}
Error _transfer_messages_to_main_queue();
void _add_page();
void _call_function(const Callable &p_callable, const Variant *p_args, int p_argcount, bool p_show_error);