From 78884caca030104557ca277dd3a41cefb70f5be8 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Wed, 15 Nov 2023 17:16:39 +0300 Subject: improve the TaskGroup API the TaskGroup now holds an Executor instead of passing it when calling its spawn method also, define a global executor `Executor<'static>` and use static lifetime instead of a lifetime placeholder This improvement simplify the code for spawning a new task. There is no need to pass the executor around. --- p2p/src/protocol.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'p2p/src/protocol.rs') diff --git a/p2p/src/protocol.rs b/p2p/src/protocol.rs index 515efc6..770b695 100644 --- a/p2p/src/protocol.rs +++ b/p2p/src/protocol.rs @@ -87,8 +87,11 @@ impl EventValue for ProtocolEvent { /// let peer_id = PeerID::random(); /// let config = Config::default(); /// +/// // Create a new Executor +/// let ex = Arc::new(Executor::new()); +/// /// // Create a new Backend -/// let backend = Backend::new(peer_id, config); +/// let backend = Backend::new(peer_id, config, ex); /// /// // Attach the NewProtocol /// let c = move |peer| NewProtocol::new(peer); -- cgit v1.2.3