summaryrefslogtreecommitdiffstats
path: root/core/object
diff options
context:
space:
mode:
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp2
-rw-r--r--core/object/message_queue.cpp59
-rw-r--r--core/object/message_queue.h2
-rw-r--r--core/object/object.cpp16
4 files changed, 10 insertions, 69 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 6b84dfcee9..7ea26c3fc5 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -1554,7 +1554,7 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
}
// The "free()" method is special, so we assume it exists and return a Callable.
- if (p_property == CoreStringNames::get_singleton()->_free) {
+ if (p_property == CoreStringName(free_)) {
r_value = Callable(p_object, p_property);
return true;
}
diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp
index 90536e58ff..9351253c6f 100644
--- a/core/object/message_queue.cpp
+++ b/core/object/message_queue.cpp
@@ -197,7 +197,7 @@ Error CallQueue::push_notification(ObjectID p_id, int p_notification) {
Message *msg = memnew_placement(buffer_end, Message);
msg->type = TYPE_NOTIFICATION;
- msg->callable = Callable(p_id, CoreStringNames::get_singleton()->notification); //name is meaningless but callable needs it
+ msg->callable = Callable(p_id, CoreStringName(notification)); //name is meaningless but callable needs it
//msg->target;
msg->notification = p_notification;
@@ -224,64 +224,7 @@ void CallQueue::_call_function(const Callable &p_callable, const Variant *p_args
}
}
-Error CallQueue::_transfer_messages_to_main_queue() {
- if (pages.size() == 0) {
- return OK;
- }
-
- CallQueue *mq = MessageQueue::main_singleton;
- DEV_ASSERT(!mq->allocator_is_custom && !allocator_is_custom); // Transferring pages is only safe if using the same alloator parameters.
-
- mq->mutex.lock();
-
- // Here we're transferring the data from this queue to the main one.
- // However, it's very unlikely big amounts of messages will be queued here,
- // so PagedArray/Pool would be overkill. Also, in most cases the data will fit
- // an already existing page of the main queue.
-
- // Let's see if our first (likely only) page fits the current target queue page.
- uint32_t src_page = 0;
- {
- if (mq->pages_used) {
- uint32_t dst_page = mq->pages_used - 1;
- uint32_t dst_offset = mq->page_bytes[dst_page];
- if (dst_offset + page_bytes[0] < uint32_t(PAGE_SIZE_BYTES)) {
- memcpy(mq->pages[dst_page]->data + dst_offset, pages[0]->data, page_bytes[0]);
- mq->page_bytes[dst_page] += page_bytes[0];
- src_page++;
- }
- }
- }
-
- // Any other possibly existing source page needs to be added.
-
- if (mq->pages_used + (pages_used - src_page) > mq->max_pages) {
- 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;
- }
-
- for (; src_page < pages_used; src_page++) {
- mq->_add_page();
- memcpy(mq->pages[mq->pages_used - 1]->data, pages[src_page]->data, page_bytes[src_page]);
- mq->page_bytes[mq->pages_used - 1] = page_bytes[src_page];
- }
-
- mq->mutex.unlock();
-
- page_bytes[0] = 0;
- 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) {
diff --git a/core/object/message_queue.h b/core/object/message_queue.h
index c2f4ad1643..9f567e4dd0 100644
--- a/core/object/message_queue.h
+++ b/core/object/message_queue.h
@@ -98,8 +98,6 @@ 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);
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 5125ab8a6e..57f8766509 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -260,7 +260,7 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
}
}
- if (p_name == CoreStringNames::get_singleton()->_script) {
+ if (p_name == CoreStringName(script)) {
set_script(p_value);
if (r_valid) {
*r_valid = true;
@@ -351,7 +351,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
}
}
- if (p_name == CoreStringNames::get_singleton()->_script) {
+ if (p_name == CoreStringName(script)) {
ret = get_script();
if (r_valid) {
*r_valid = true;
@@ -672,7 +672,7 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Call
}
bool Object::has_method(const StringName &p_method) const {
- if (p_method == CoreStringNames::get_singleton()->_free) {
+ if (p_method == CoreStringName(free_)) {
return true;
}
@@ -698,7 +698,7 @@ int Object::_get_method_argument_count_bind(const StringName &p_method) const {
}
int Object::get_method_argument_count(const StringName &p_method, bool *r_is_valid) const {
- if (p_method == CoreStringNames::get_singleton()->_free) {
+ if (p_method == CoreStringName(free_)) {
if (r_is_valid) {
*r_is_valid = true;
}
@@ -787,7 +787,7 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) {
Variant Object::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
- if (p_method == CoreStringNames::get_singleton()->_free) {
+ if (p_method == CoreStringName(free_)) {
//free must be here, before anything, always ready
#ifdef DEBUG_ENABLED
if (p_argcount != 0) {
@@ -850,7 +850,7 @@ Variant Object::callp(const StringName &p_method, const Variant **p_args, int p_
Variant Object::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
- if (p_method == CoreStringNames::get_singleton()->_free) {
+ if (p_method == CoreStringName(free_)) {
// Free is not const, so fail.
r_error.error = Callable::CallError::CALL_ERROR_METHOD_NOT_CONST;
return Variant();
@@ -979,7 +979,7 @@ void Object::set_script(const Variant &p_script) {
}
notify_property_list_changed(); //scripts may add variables, so refresh is desired
- emit_signal(CoreStringNames::get_singleton()->script_changed);
+ emit_signal(CoreStringName(script_changed));
}
void Object::set_script_instance(ScriptInstance *p_instance) {
@@ -1654,7 +1654,7 @@ void Object::clear_internal_resource_paths() {
}
void Object::notify_property_list_changed() {
- emit_signal(CoreStringNames::get_singleton()->property_list_changed);
+ emit_signal(CoreStringName(property_list_changed));
}
void Object::_bind_methods() {