aboutsummaryrefslogtreecommitdiff
path: root/p2p/examples
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/examples')
-rw-r--r--p2p/examples/chat.rs4
-rw-r--r--p2p/examples/monitor.rs2
-rw-r--r--p2p/examples/peer.rs2
-rw-r--r--p2p/examples/shared/mod.rs8
4 files changed, 7 insertions, 9 deletions
diff --git a/p2p/examples/chat.rs b/p2p/examples/chat.rs
index cc822d9..4eafb07 100644
--- a/p2p/examples/chat.rs
+++ b/p2p/examples/chat.rs
@@ -121,7 +121,7 @@ fn main() {
let ex = Arc::new(Executor::new());
// Create a new Backend
- let backend = Backend::new(&key_pair, config, ex.clone());
+ let backend = Backend::new(&key_pair, config, ex.clone().into());
let (ctrlc_s, ctrlc_r) = channel::unbounded();
let handle = move || ctrlc_s.try_send(()).unwrap();
@@ -133,7 +133,7 @@ fn main() {
let username = cli.username;
// Attach the ChatProtocol
- let c = move |peer| ChatProtocol::new(&username, peer, ex_cloned.clone());
+ let c = move |peer| ChatProtocol::new(&username, peer, ex_cloned.clone().into());
backend.attach_protocol::<ChatProtocol>(c).await.unwrap();
// Run the backend
diff --git a/p2p/examples/monitor.rs b/p2p/examples/monitor.rs
index b074352..019f751 100644
--- a/p2p/examples/monitor.rs
+++ b/p2p/examples/monitor.rs
@@ -51,7 +51,7 @@ fn main() {
let ex = Arc::new(Executor::new());
// Create a new Backend
- let backend = Backend::new(&key_pair, config, ex.clone());
+ let backend = Backend::new(&key_pair, config, ex.clone().into());
let (ctrlc_s, ctrlc_r) = channel::unbounded();
let handle = move || ctrlc_s.try_send(()).unwrap();
diff --git a/p2p/examples/peer.rs b/p2p/examples/peer.rs
index 06586b6..db747c9 100644
--- a/p2p/examples/peer.rs
+++ b/p2p/examples/peer.rs
@@ -51,7 +51,7 @@ fn main() {
let ex = Arc::new(Executor::new());
// Create a new Backend
- let backend = Backend::new(&key_pair, config, ex.clone());
+ let backend = Backend::new(&key_pair, config, ex.clone().into());
let (ctrlc_s, ctrlc_r) = channel::unbounded();
let handle = move || ctrlc_s.try_send(()).unwrap();
diff --git a/p2p/examples/shared/mod.rs b/p2p/examples/shared/mod.rs
index 8065e63..57d89ef 100644
--- a/p2p/examples/shared/mod.rs
+++ b/p2p/examples/shared/mod.rs
@@ -1,9 +1,7 @@
-use std::{num::NonZeroUsize, thread};
+use std::{num::NonZeroUsize, sync::Arc, thread};
use easy_parallel::Parallel;
-use smol::{channel, future, future::Future};
-
-use karyon_core::async_util::Executor;
+use smol::{channel, future, future::Future, Executor};
/// Returns an estimate of the default amount of parallelism a program should use.
/// see `std::thread::available_parallelism`
@@ -14,7 +12,7 @@ fn available_parallelism() -> usize {
}
/// Run a multi-threaded executor
-pub fn run_executor<T>(main_future: impl Future<Output = T>, ex: Executor<'_>) {
+pub fn run_executor<T>(main_future: impl Future<Output = T>, ex: Arc<Executor<'_>>) {
let (signal, shutdown) = channel::unbounded::<()>();
let num_threads = available_parallelism();