Refactor CallQueue flushing for clarity

This commit is contained in:
Pedro J. Estébanez 2023-06-23 13:27:34 +02:00
parent ada712e06a
commit c85beb8106
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;
}
@ -278,6 +274,14 @@ Error CallQueue::flush() {
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);