diff --git a/src/bin/simulation.rs b/src/bin/simulation.rs index 673cfce..cfb9595 100644 --- a/src/bin/simulation.rs +++ b/src/bin/simulation.rs @@ -5,7 +5,7 @@ use troll_patrol::{ extra_info::ExtraInfo, - get_date, increment_simulated_date, + increment_simulated_date, simulation::{ bridge::Bridge, censor::{Censor, Hides::*, Speed::*, Totality::*}, @@ -120,10 +120,8 @@ pub async fn main() { let mut tp = 0; // Main loop - for _ in 0..config.num_days { - let la_net = HyperNet { - hostname: format!("http://localhost:{}", config.la_port), - }; + for day in 1..=config.num_days { + println!("Starting day {} of the simulation", day); // USER TASKS diff --git a/src/simulation/extra_infos_server.rs b/src/simulation/extra_infos_server.rs index 827b5d3..1f96eac 100644 --- a/src/simulation/extra_infos_server.rs +++ b/src/simulation/extra_infos_server.rs @@ -11,7 +11,7 @@ use serde_json::json; use std::{collections::HashSet, convert::Infallible, net::SocketAddr, time::Duration}; use tokio::{ spawn, - sync::{broadcast, mpsc, oneshot}, + sync::{mpsc, oneshot}, time::sleep, }; @@ -44,12 +44,8 @@ async fn serve_extra_infos( pub async fn server() { let (context_tx, context_rx) = mpsc::channel(32); let request_tx = context_tx.clone(); - let shutdown_cmd_tx = context_tx.clone(); - let (shutdown_tx, mut shutdown_rx) = broadcast::channel(16); - let kill_context = shutdown_tx.subscribe(); - let context_manager = - spawn(async move { create_context_manager(context_rx, kill_context).await }); + spawn(async move { create_context_manager(context_rx).await }); let addr = SocketAddr::from(([127, 0, 0, 1], 8004)); let make_svc = make_service_fn(move |_conn: &AddrStream| { @@ -75,13 +71,9 @@ pub async fn server() { } } -async fn create_context_manager( - context_rx: mpsc::Receiver, - mut kill: broadcast::Receiver<()>, -) { +async fn create_context_manager(context_rx: mpsc::Receiver) { tokio::select! { create_context = context_manager(context_rx) => create_context, - _ = kill.recv() => {println!("Shut down context_manager");}, } } @@ -98,9 +90,6 @@ async fn context_manager(mut context_rx: mpsc::Receiver) { } sleep(Duration::from_millis(1)).await; } - Shutdown { shutdown_sig } => { - drop(shutdown_sig); - } } } } @@ -111,9 +100,6 @@ enum Command { req: Request, sender: oneshot::Sender, Infallible>>, }, - Shutdown { - shutdown_sig: broadcast::Sender<()>, - }, } fn add_extra_infos(extra_infos_pages: &mut Vec, request: Bytes) -> Response {