aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/monitor.rs
diff options
context:
space:
mode:
authorhozan23 <hozan23@proton.me>2023-11-15 17:16:39 +0300
committerhozan23 <hozan23@proton.me>2023-11-15 17:16:39 +0300
commit78884caca030104557ca277dd3a41cefb70f5be8 (patch)
treec33650dfe44a219e395dff1966d298b58b09acb3 /p2p/src/monitor.rs
parentf0729022589ee8e48b5558ab30462f95d06fe6df (diff)
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.
Diffstat (limited to 'p2p/src/monitor.rs')
-rw-r--r--p2p/src/monitor.rs12
1 files changed, 10 insertions, 2 deletions
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;
///