diff options
Diffstat (limited to 'core/object/message_queue.cpp')
-rw-r--r-- | core/object/message_queue.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index de71295ee5..90536e58ff 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -35,15 +35,17 @@ #include "core/object/class_db.h" #include "core/object/script_language.h" +#include <stdio.h> + #ifdef DEV_ENABLED // Includes safety checks to ensure that a queue set as a thread singleton override // is only ever called from the thread it was set for. -#define LOCK_MUTEX \ - if (this != MessageQueue::thread_singleton) { \ - DEV_ASSERT(!this->is_current_thread_override); \ - mutex.lock(); \ - } else { \ - DEV_ASSERT(this->is_current_thread_override); \ +#define LOCK_MUTEX \ + if (this != MessageQueue::thread_singleton) { \ + DEV_ASSERT(!is_current_thread_override); \ + mutex.lock(); \ + } else { \ + DEV_ASSERT(is_current_thread_override); \ } #else #define LOCK_MUTEX \ @@ -93,7 +95,7 @@ Error CallQueue::push_callablep(const Callable &p_callable, const Variant **p_ar if ((page_bytes[pages_used - 1] + room_needed) > uint32_t(PAGE_SIZE_BYTES)) { if (pages_used == max_pages) { - ERR_PRINT("Failed method: " + p_callable + ". Message queue out of memory. " + error_text); + fprintf(stderr, "Failed method: %s. Message queue out of memory. %s\n", String(p_callable).utf8().get_data(), error_text.utf8().get_data()); statistics(); UNLOCK_MUTEX; return ERR_OUT_OF_MEMORY; @@ -144,7 +146,7 @@ Error CallQueue::push_set(ObjectID p_id, const StringName &p_prop, const Variant if (ObjectDB::get_instance(p_id)) { type = ObjectDB::get_instance(p_id)->get_class(); } - ERR_PRINT("Failed set: " + type + ":" + p_prop + " target ID: " + itos(p_id) + ". Message queue out of memory. " + error_text); + fprintf(stderr, "Failed set: %s: %s target ID: %s. Message queue out of memory. %s\n", type.utf8().get_data(), String(p_prop).utf8().get_data(), itos(p_id).utf8().get_data(), error_text.utf8().get_data()); statistics(); UNLOCK_MUTEX; @@ -181,7 +183,7 @@ Error CallQueue::push_notification(ObjectID p_id, int p_notification) { if ((page_bytes[pages_used - 1] + room_needed) > uint32_t(PAGE_SIZE_BYTES)) { if (pages_used == max_pages) { - ERR_PRINT("Failed notification: " + itos(p_notification) + " target ID: " + itos(p_id) + ". Message queue out of memory. " + error_text); + fprintf(stderr, "Failed notification: %d target ID: %s. Message queue out of memory. %s\n", p_notification, itos(p_id).utf8().get_data(), error_text.utf8().get_data()); statistics(); UNLOCK_MUTEX; return ERR_OUT_OF_MEMORY; @@ -254,7 +256,7 @@ Error CallQueue::_transfer_messages_to_main_queue() { // Any other possibly existing source page needs to be added. if (mq->pages_used + (pages_used - src_page) > mq->max_pages) { - ERR_PRINT("Failed appending thread queue. Message queue out of memory. " + mq->error_text); + fprintf(stderr, "Failed appending thread queue. Message queue out of memory. %s\n", mq->error_text.utf8().get_data()); mq->statistics(); mq->mutex.unlock(); return ERR_OUT_OF_MEMORY; @@ -460,8 +462,8 @@ void CallQueue::statistics() { } break; } if (null_target) { - //object was deleted - print_line("Object was deleted while awaiting a callback"); + // Object was deleted. + fprintf(stdout, "Object was deleted while awaiting a callback.\n"); null_count++; } @@ -479,19 +481,19 @@ void CallQueue::statistics() { } } - print_line("TOTAL PAGES: " + itos(pages_used) + " (" + itos(pages_used * PAGE_SIZE_BYTES) + " bytes)."); - print_line("NULL count: " + itos(null_count)); + fprintf(stdout, "TOTAL PAGES: %d (%d bytes).\n", pages_used, pages_used * PAGE_SIZE_BYTES); + fprintf(stdout, "NULL count: %d.\n", null_count); for (const KeyValue<StringName, int> &E : set_count) { - print_line("SET " + E.key + ": " + itos(E.value)); + fprintf(stdout, "SET %s: %d.\n", String(E.key).utf8().get_data(), E.value); } for (const KeyValue<Callable, int> &E : call_count) { - print_line("CALL " + E.key + ": " + itos(E.value)); + fprintf(stdout, "CALL %s: %d.\n", String(E.key).utf8().get_data(), E.value); } for (const KeyValue<int, int> &E : notify_count) { - print_line("NOTIFY " + itos(E.key) + ": " + itos(E.value)); + fprintf(stdout, "NOTIFY %d: %d.\n", E.key, E.value); } UNLOCK_MUTEX; |