Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any closure to be passed as an executor #1686

Merged
merged 2 commits into from
Sep 3, 2020

Conversation

thomaseizinger
Copy link
Contributor

Previously, only dedicated implementations of Executor could be passed to set_executor of NetworkConfig. To pass a closure, one had to use executor_fn. Unfortunately, that function isn't exposed on the SwarmBuilder and hence cannot be used from the outside.

With this patch, any closure that takes a future can be passed as an executor.

This allows us to:

  • simplify the build function of NetworkConfig by removing the SpawnImpl
  • use functions like tokio::spawn or async_std::task::spawn as the executor on the SwarmBuilder because they share the same interface

I believe this is a breaking change because we have to remove certain impl blocks from libp2p-core.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

I am not sure whether we depend on the & T or &mut T impl anywhere.

In case no one else knows I will take another look.

@romanb romanb merged commit 3100444 into libp2p:master Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants