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/monitor.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'p2p/src/monitor.rs') diff --git a/p2p/src/monitor.rs b/p2p/src/monitor.rs index ee0bf44..fbbf43f 100644 --- a/p2p/src/monitor.rs +++ b/p2p/src/monitor.rs @@ -13,11 +13,19 @@ use karyons_net::Endpoint; /// # Example /// /// ``` +/// use std::sync::Arc; +/// +/// use smol::Executor; +/// /// use karyons_p2p::{Config, Backend, PeerID}; +/// /// async { /// -/// let backend = Backend::new(PeerID::random(), Config::default()); -/// +/// // Create a new Executor +/// let ex = Arc::new(Executor::new()); +/// +/// let backend = Backend::new(PeerID::random(), Config::default(), ex); +/// /// // Create a new Subscription /// let sub = backend.monitor().await; /// -- cgit v1.2.3