-
-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single- and multi-threading support for Callable::from_fn
#588
Comments
This is mostly a direct consequence of #18 not yet being implemented. Mid-term, I see the option to have two functions:
|
Callable::from_fn
is not usable for connecting signalsCallable::from_fn
@Bromeon I'm working on the Signal support PR, and while testing my design I remembered that callable requiring Send + Sync essentially means you can't interact with Godot from inside them, which extremely limits their usefulness. In my experience, 95% of the time callables were used to connect to signals, and so I had to make this workaround that bypasses the Send + Sync: https://github.com/Houtamelo/houtamelo_utils_gdext/blob/main/src/connect_with_deferred.rs. I use it every single time I want to connect to a signal because otherwise there isn't much I can do with the Send + Sync bounds in place. I think it would be reasonable if we at least had a |
Fair point, maybe it's worth providing this as an interim solution until we have a solid design. We should probably explicitly state in the docs that such an API will be removed once there is a proper solution. |
Callable::from_fn
requiresSend + Sync
from closures butGd<T>
is not. I saw in few bugsCallable::from_fn
is mentioned as an alternative to using function nameBase::callable
/Callable::from_object_method
(which are not type safe because function name can be misspelled) but it doesn't really work.Basically this limitation limits usefulness of
Callable::from_fn
quite a bit.Possibly related to #18 but usecase is different. Maybe
Callable
can be adjusted instead ofGd<T>
.Code
Error
The text was updated successfully, but these errors were encountered: