I have a crate that optionally supports tokio (the crate can spawn a runtime, and the application likely uses networking along with it).

This crate, regardless of whether tokio support is enabled or not, needs to perform some communication between threads (and possibly tasks). It uses three channel types: oneshot, mpsc and broadcast.

tokio happens to have all three of these. Currently my crate uses tokio for these channels, which means it'll always pull in tokio (using its sync feature), even if one doesn't use a tokio runtime.

There are people who have voiced concerns about developers pulling in tokio as a dependency too liberally -- and there are non-tokio alternatives I could use for the non-tokio use-case. So now I'm wondering how far one should take this tokio-avoidance? (For the record, I like tokio, so I see no reason to avoid it, but I do try to take into consideration what people write on here and other Rust forums).

Would you prefer to have three other special-purpose crates pulled in as dependencies or tokio (with only the sync feature)?

2 posts - 2 participants

Read full topic