Make client parametric on executor to use
Currently libtiny_client only works with tokio as it uses tokio's spawn functions. I think it'd be good to make it work with different executors using a "spawn" function passed on initialization, for two reasons:
- It would make the library more usable, e.g. in an application that uses
async-stdyou could still uselibtiny_clientwithout adding yet another executor to your app. - In #154 I think it'll be better if we use GTK/Glib's event loop as executor instead of tokio. I don't have a prototype yet but I think using glib::MainContext::spawn_local would make the code simpler (no need for messaging, I think we could share widgets with the tasks and update them directly etc.).
In my original message I forgot that simply using executor-specific spawn functions is not enough; I also need executor-specific IO primitives.
One related example is this code: https://github.com/sdroege/async-tungstenite/blob/master/src/tokio.rs#L296-L363 By implementing futures' and tokio's AsyncRead and AsyncWrite it's possible to use this type with both futures' and tokio's executors.
I think we'll need a similar compat layer with types that implement the relevant traits for executors.
Not sure what traits I'll need to implement for GTK's event loop, but we'll need tokio's AsyncRead and AsyncWrite.
That said, for #154 I think we should simply spawn a new thread for the clients and implement the communication with messaging, and ship a MVP. The rest can be done later.