-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add spawn_future_with_priority and spawn_future_local_with_priority #1214
base: main
Are you sure you want to change the base?
Conversation
IMHO this is not an idiomatic way to handle the problem. We are polluting the library with a lot of combinations The same problems exists for timeouts, and other glib sources. In #1033 I was trying to build a futures module where you can use a builder pattern to reduce the number of spawn combinations. For example, that PR introduced a
Note: the context is optional, the priority is optional. That's 1 API to handle all the possible spawn combinations. That also resembles the API of |
Followup to gtk-rs#1201 Allow to set custom priority for the spawned futures.
dce1b09
to
6cbf4ef
Compare
I like that approach @ranfdev |
The Builder is nice yes, but every app will still end up with convenient wrappers around it. It won't cut down on the boilerplate required compared to Now making wrappers for these on the application side is harmless for the most part. But if that's the case I'd say we'd remove #1201 as well or get the wrappers on the bindings side. |
Yes I think these should be replaced by the builder too. |
I would keep the functions #1201 under the futures scope, eg: Only because spawn_local is used 10x more than spawn_local_with_priority, so I think it's nice having a shorthand for the common case. Also, you can
|
Most applications that use ::spawn actually wanted/should have been using a spawn with default_idle, as default has higher priority than GTK's rendering machinery and can lead to missing frames. I expect 9/10 times this is the case. |
Ah, I didn't expect that. Can we make every For sure I've spawned many futures with |
Yea, so I just opened an MR for loupe which you can use as reference. |
That's also a more general problem then. If that's not suitable for GTK applications then something will have to change in GTK. |
Like @sdroege said ideally that would be changed on the GTK side. |
It doesn't even seem like a good default for GTK. It depends on how you want your future to be ordered in relation to the drawing operations. It probably makes sense to export the GDK priority as a constant though. |
Followup to #1201
Allow to set custom priority for the spawned futures.