SegsEngine
SegsEngine copied to clipboard
Introduce sanity to the signal emission/connection.
Just take a look at the following bit of logic from HTTPRequest class:
bool HTTPRequest::_handle_response(bool *ret_value) {
if (!client->has_response()) {
call_deferred("_request_done", RESULT_NO_RESPONSE, 0, PoolStringArray(), PoolByteArray());
*ret_value = true;
return true;
}
call_deferred("_request_done" is basically storing a function-to-call later as a name + args
and _request_done is a function of this class, registered here:
MethodBinder::bind_method(D_METHOD("_request_done"), &HTTPRequest::_request_done);
That will be looked-up by StringName ( slightly accelerated form of interning string class ) So we perform some string construction, lookups, etc, just to do something that in Qt is a simple
connect(this,&HTTPRequest::request_done,this,&HTTPRequest::on_request_done,Qt::QueuedConnection);
And without mentioning Qt at all, this can be done using a queue storing std::function'like objects instead.
This is mostly 'done' for signal handlers ( replaced with Callable types ), the other part of the equation -> 'signals' are still plain strings.