ipfs-rust / ipfs-embed

A small embeddable ipfs implementation
344 stars 47 forks source link

Add support for different async executors (initially async-std (via `async_global_executor`) and tokio 1.x). #70

Closed wngr closed 3 years ago

wngr commented 3 years ago

This lets user choose another async executor. An Executor struct is added to abstract over different executors. Each spawned Future returns a JoinHandle, with which the task can either be cancelled (by dropping the handle), or detached. Initial support is added for async-std (via async_global_executor) and tokio 1.x.

I went with this approach rather than adding an Executor trait, because I think we can add support for additional async executors if the need arises, and we can get around unnecessary allocations when spawning futures. With this, the additional complexity is hidden in feature flags and does not leak into the APIs, and I don't think the freedom of a trait based approach is necessary.

Further, when the tokio feature is set, tokio is also used to configure libp2p's TCP transport.

Closes #68

wngr commented 3 years ago

Feel free to merge, I don't have access to the repo.