diff --git a/core/src/nodes/collection.rs b/core/src/nodes/collection.rs index 347a8c9a..eb346092 100644 --- a/core/src/nodes/collection.rs +++ b/core/src/nodes/collection.rs @@ -309,7 +309,7 @@ where { /// Creates a new empty collection. If `executor` is `Some`, uses the given executor to spawn /// tasks. Otherwise, runs tasks locally. - pub fn new(executor: Option>) -> Self { + pub fn new(executor: Option>) -> Self { CollectionStream { inner: tasks::Manager::new(executor), nodes: Default::default(), diff --git a/core/src/nodes/network.rs b/core/src/nodes/network.rs index 16594c27..c6059209 100644 --- a/core/src/nodes/network.rs +++ b/core/src/nodes/network.rs @@ -688,7 +688,7 @@ where TPeerId: Eq + Hash + Clone, { /// Creates a new node events stream. - pub fn new(transport: TTrans, local_peer_id: TPeerId, executor: Option>) -> Self { + pub fn new(transport: TTrans, local_peer_id: TPeerId, executor: Option>) -> Self { // TODO: with_capacity? Network { listeners: ListenersStream::new(transport), @@ -706,7 +706,7 @@ where /// Creates a new node event stream with incoming connections limit. pub fn new_with_incoming_limit(transport: TTrans, - local_peer_id: TPeerId, executor: Option>, incoming_limit: Option) -> Self + local_peer_id: TPeerId, executor: Option>, incoming_limit: Option) -> Self { Network { incoming_limit, diff --git a/core/src/nodes/tasks/manager.rs b/core/src/nodes/tasks/manager.rs index ad891c4a..47c0a63c 100644 --- a/core/src/nodes/tasks/manager.rs +++ b/core/src/nodes/tasks/manager.rs @@ -65,7 +65,7 @@ pub struct Manager { /// Custom executor where we spawn the nodes' tasks. If `None`, then we push tasks to the /// `local_spawns` list instead. - executor: Option>, + executor: Option>, /// If no executor is available, we move tasks to this set, and futures are polled on the /// current thread instead. @@ -136,7 +136,7 @@ pub enum Event<'a, I, O, H, E, HE, T, C = PeerId> { impl Manager { /// Creates a new task manager. If `Some` is passed, uses the given executor to spawn tasks. /// Otherwise, background tasks are executed locally when you call `poll`. - pub fn new(executor: Option>) -> Self { + pub fn new(executor: Option>) -> Self { let (tx, rx) = mpsc::channel(1); Self { tasks: FnvHashMap::default(), diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 3a02aa91..09a1c7f4 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -572,7 +572,7 @@ impl<'a> PollParameters for SwarmPollParameters<'a> { pub struct SwarmBuilder { incoming_limit: Option, - executor: Option>, + executor: Option>, local_peer_id: PeerId, transport: TTransport, behaviour: TBehaviour, @@ -626,13 +626,13 @@ where TBehaviour: NetworkBehaviour, /// Sets the executor to use to spawn background tasks. /// /// By default, uses a threads pool. - pub fn executor(mut self, executor: impl Executor + 'static) -> Self { + pub fn executor(mut self, executor: impl Executor + Send + 'static) -> Self { self.executor = Some(Box::new(executor)); self } /// Shortcut for calling `executor` with an object that calls the given closure. - pub fn executor_fn(mut self, executor: impl Fn(Pin + Send>>) + 'static) -> Self { + pub fn executor_fn(mut self, executor: impl Fn(Pin + Send>>) + Send + 'static) -> Self { struct SpawnImpl(F); impl + Send>>)> Executor for SpawnImpl { fn exec(&self, f: Pin + Send>>) {