dbus2 / zbus

Rust D-Bus crate.
Other
316 stars 70 forks source link

Make signal emission in `interface` great again #871

Open zeenix opened 1 week ago

zeenix commented 1 week ago

In zbus 1.x times, the signal methods in interface used to take &self and didn't require the strange SignalContext etc. That API however, made use of thread locals. When we reworked the API in 2.x to be completely async, it was no longer possible to use thread locals anymore since our futures could potentially be moved between threads of an async runtime w/o us knowing.

However, I think we can make the same/similar API work again w/o using any thread locals. The rough (I haven't yet thought it through) is:

This simple code demonstrates the idea: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8263c4aff9df3bdb2e432affc0957bb8

pros:

cons:

zeenix commented 1 week ago

CC @elmarco @danieldg