From 0b76a1633e0d41df42a4660aecf2a08003865c66 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 4 Feb 2025 01:43:04 +0100 Subject: [PATCH] No need for a Mutex There's no need for a `Mutex` in `StatefulIocaine`, so drop it - keep only `Arc`. Signed-off-by: Gergely Nagy --- src/app.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/app.rs b/src/app.rs index ff2d852..0a4dc3f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,14 +10,14 @@ use axum::{ routing::get, Router, }; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use crate::{ assembled_statistical_sequences::AssembledStatisticalSequences, config::Config, garglebargle::GargleBargle, wurstsalat_generator_pro::WurstsalatGeneratorPro, }; -type StatefulIocaine = Arc>; +type StatefulIocaine = Arc; #[derive(Debug)] pub struct Iocaine { @@ -46,7 +46,7 @@ impl Iocaine { pub async fn run(self) -> std::result::Result<(), std::io::Error> { let bind = &self.config.server.bind.clone(); - let state: StatefulIocaine = Arc::new(Mutex::new(self)); + let state: StatefulIocaine = Arc::new(self); let app = Router::new() .route("/", get(poison_root)) .route("/{*path}", get(poison_path)) @@ -87,11 +87,7 @@ fn poison(iocaine: &StatefulIocaine, headers: axum::http::HeaderMap, path: &str) .to_str() .unwrap(); - Html(AssembledStatisticalSequences::generate( - &iocaine.lock().unwrap(), - host, - path, - )) + Html(AssembledStatisticalSequences::generate(iocaine, host, path)) } async fn poison_root(