Use coroutines to run dialogs asynchronously - #172
Conversation
mvo5
left a comment
There was a problem hiding this comment.
I have not looked in detail but I would be very hesitant here, its an interesting idea and probably fun to play with - but staying as close as possible to gtk is preferable IMHO. I have a hard time maintaining this as is so anything that adds burden feels not ideal. Sorry if that sounds disappointing.
|
@mvo5 I totally understand your point. The piece of code in this PR is awful (in a part where coroutines are defined). I don't mind if this PR will be rejected. I'd just want to clarify the future direction, so, I could contribute to the project. The problem with sticking to Gtk is that Gtk4 does not have synchronous dialog API anymore. See https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-blocking-dialog-functions So, all the places which use dialogs and It'll be not possible to have functions like The point of using coroutines is that application's code may still look the same (or resemble the original code) but be asynchronous. In this PR I've mentioned Rust above, so, Gtk-rs solves this by wrapping signals and running futures (coroutines) on top of Glib event loop. See gtk::Dialog::run_future. I successfully used Rust async functions in a few rewrites from C++/Gtk3 to Rust/Gtk4. So, I gave C++ coroutines a try to replicate the pattern. |
|
What about converting to Rust? |
1b1f178 to
86522a1
Compare
8f7af85 to
1571aba
Compare
|
This PR evolved a bit.
|
7f9e33f to
2eca9d5
Compare
71b7ff7 to
e833243
Compare
b5cb7ec to
a1aea0c
Compare
40608d7 to
5ea4276
Compare
|
Generally speaking synaptic is built around the glib/gtk ecosystem which operates with a main event loop in a fully asynchronous (but single threaded) fashion. To interface with APT you want to have a single apt thread or process and message queues to the main thread glib event loop. Importantly you may never call APT functions from different threads. Vendoring a third-party library is violating general expectations on Debian software. Overall there is not much point in this work. As bad as this sounds synaptic in the end needs to migrate to a multi-process architecture anyway where the privileged operations are clearly separated from the user space components. The architecture of the APT daemon is an ongoing process of intermittent thoughts :D |
I'll be honest. I have no idea if this works properly. Few AIs helped me to craft this code. Generally, I'd like to have something like
async/awaitin Rust, so I gave it a try.