glib: Add helper functions to spawn a non-Send future on the curren…#902
glib: Add helper functions to spawn a non-Send future on the curren…#902sdroege wants to merge 1 commit intogtk-rs:mainfrom
Send future on the curren…#902Conversation
|
|
||
| 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.
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.
Or directly make these two functions methods of MainContext and add doc aliases on them.
There was a problem hiding this comment.
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.
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.
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.
shouldn't this be named spawn_local_with_priority?
…t thread-default
MainContextCC @elmarco @pbor @A6GibKm