Skip to content

Remove dependency on tokio/rt #290

@AadamZ5

Description

@AadamZ5

Is your feature request related to a problem? Please describe.
Since this project is a library, it is unfavorable that it includes/requires the runtime from tokio/rt. If a project using the async-std runtime or some other runtime tries to use this project, the tokio runtime will now be needed to be running in addition to it, if there are no compatibility issues. Additionally, if a project uses a different version of tokio the runtimes may be incompatible.

Specifically, calls to tokio::spawn will panic if not called within a Tokio runtime. This is bad news for projects that include this crate and use a different runtime.

Describe the solution you'd like
Remove dependency on tokio/rt feature, and any calls to tokio::spawn in library code.

Describe alternatives you've considered
N/A

Additional context
A library crate bringing it's own async runtime is bad, and forces the consuming project of this crate to make more significant decisions about using the same runtime, having a larger binary size with two runtimes, or in the worst case, compatibility issues.

Note that removing the tokio/rt feature means that some portions that rely on tokio::task::JoinSet can not compile. Consider refactoring these areas with futures::stream::FuturesUnordered from the futures crate. Additionally, some spots that use tokio::spawn and JoinHandle may be replaceable with plain Pin<Box<dyn Future<Output = T> + Send + Sync + 'static>>s (but will now need polled/awaited somehow! spawn took care of that before). And in complex cases, you may even consider futures::future::shared to poll or await the same future from multiple spots.

I understand this may be a large refactor, perhaps one for a major release. Async Rust also gets a lot harder when we can't just spawn tasks, adding to the complexity of this refactor.

Metadata

Metadata

Assignees

Labels

P3Low: nice-to-have, long-term, or exploratoryT-coreCore library changesenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions