-
-
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
glib: Add helper functions to spawn a non-Send
future on the curren…
#902
base: main
Are you sure you want to change the base?
Conversation
@@ -199,7 +199,7 @@ pub use self::bridged_logging::{rust_log_handler, GlibLogger, GlibLoggerDomain, | |||
pub mod subclass; | |||
|
|||
mod main_context_futures; | |||
pub use main_context_futures::{JoinError, JoinHandle}; | |||
pub use main_context_futures::{spawn, spawn_with_priority, JoinError, JoinHandle}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of the functions is a bit suboptimal as there's also this set of functions: https://gtk-rs.org/gtk-rs-core/git/docs/glib/fn.spawn_async.html
Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spawn_main_context
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or directly make these two functions methods of MainContext
and add doc aliases on them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are already methods with that name on MainContext
. The goal here is to have a function that gets the correct main context instance and then calls the method on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spawn_on_thread_default_main_context()
could work of course, but that's almost as long as the implementation of the function :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe could move this into a glib::futures
module, and also potentially move some other things in there. Not sure.
cc1fa87
to
f16b13d
Compare
This is apparently not too useful because |
f16b13d
to
3f5b6cc
Compare
…d-)default `MainContext`
3f5b6cc
to
1c7e825
Compare
Maybe something like this. It would take the thread-default main context if any, otherwise the global default. And then make sure that the current thread actually owns it. |
I guess there is not really any interest in having such a function? Let's close this then? |
Huh? This would definitely be helpful. Apps currently use a macro for this. |
I got no feedback at all so I assumed nobody actually needed it :) As it's apparently useful to you, do you have suggestions about the name and where to put it? Where/how would you expect it? |
Note that they do |
For an application that didn't configure a custom thread default main context this would end up the same. |
Conclusion seems to be to make a new |
Has anyone started working in that direction? |
I'm not aware of anybody having started such work |
/// | ||
/// Panics if there is no thread-default main context on this thread and if this thread | ||
/// does not own the global default main context. | ||
pub fn spawn_with_priority<R: 'static, F: Future<Output = R> + 'static>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be named spawn_local_with_priority?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for above
…t thread-default
MainContext
CC @elmarco @pbor @A6GibKm