From eb497a5468b8ed624c5e3f0b840a9051312684ec Mon Sep 17 00:00:00 2001 From: some body Date: Thu, 16 Sep 2021 15:07:56 -0500 Subject: [PATCH] RircdState::run() --- src/state.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/state.rs b/src/state.rs index 18e3d03..31c1ac0 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,5 +1,6 @@ use eyre::Result; use async_trait::async_trait; +use tokio::task::JoinHandle; use std::time::Instant; use std::sync::Arc; use tokio::sync::oneshot; @@ -38,14 +39,19 @@ impl RircdState { self.endpoints.iter().filter(|ep| ep.is_active()).for_each(|endpoint| { let endpoint_name = endpoint.name(); let (success_status_send,success_status_recv) = oneshot::channel::>(); - tokio::spawn(endpoint.listen(success_status_send)); + tokio::spawn(endpoint.clone().listen(success_status_send)); //TODO color err msg - println!("starting {} | {}", endpoint_name, - match success_status_recv.await { - Ok(_) => format!("SUCCEEDED |"), - Err(e) => format!("FAILED| <{}>", e), - }); + //TODO paralelize and sync at the end + tokio::task::spawn_local(async move { + println!("starting {} | {}", endpoint_name, + match success_status_recv.await { + Ok(_) => format!("SUCCEEDED |"), + Err(e) => format!("FAILED| <{}>", e), + }); + }); }); + + Ok(()) } }