Open sdroege opened 5 years ago
Thanks for the info.
When I was writing an app with gtk-rs, I could not find anything close to this in gtk-rs; and I needed something that would work on stable rust.
Is there any difference in how they work and advantages in using this one instead of the one from glib?
I'll check if there is any. If gtk-rs already has executors and they are usable then there isn't much use in this crate.
In addition there's the Promise struct, which looks like a normal futures::channel::oneshot channel
It seems very similar; though I didn't compare exact semantics.
When I was writing an app with gtk-rs, I could not find anything close to this in gtk-rs; and I needed something that would work on stable rust.
gtk-rs
has futures support since at least two releases :) Maybe we should advertise a bit more though?
You have to enable the futures
feature of the various crates, and then you get glib::MainContext
as a futures executor. Latest gtk-rs
release uses the new futures from 1.36 in std
and work fine on stable Rust.
Is there any difference in how they work and advantages in using this one instead of the one from glib?
I'll check if there is any. If gtk-rs already has executors and they are usable then there isn't much use in this crate.
See https://github.com/gtk-rs/examples/blob/pending/src/bin/gio_futures.rs and https://github.com/gtk-rs/examples/blob/pending/src/bin/gio_futures_await.rs (the second of course still needs nightly because of await
).
There's also some more code in the unit tests https://github.com/gtk-rs/glib/blob/d97731ccbb2a9391b42aa2716f4b2423dcfdf966/src/source_futures.rs#L372-L441 https://github.com/gtk-rs/glib/blob/d97731ccbb2a9391b42aa2716f4b2423dcfdf966/src/main_context_futures.rs#L365-L436.
Let me know if you think something's missing there for your use-cases.
From what I can see this crate provides some wrapper around the main loop that acts as a futures executor, but the glib bindings already provide exactly the same. Is there any difference in how they work and advantages in using this one instead of the one from glib? Note that you have to enable the "futures" feature in these crates to enable this code.
In addition there's the
Promise
struct, which looks like a normalfutures::channel::oneshot
channel. What does it provide on top of that?