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.
This lets user choose another async executor. An
Executor
struct is added to abstract over different executors. Each spawnedFuture
returns aJoinHandle
, with which the task can either be cancelled (by dropping the handle), or detached. Initial support is added for async-std (viaasync_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