1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

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;
}
@@ -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);