No need for a Mutex
Some checks are pending
build / binary (push) Waiting to run
build / binary-static (push) Waiting to run
build / container (push) Waiting to run
build / clippy (push) Waiting to run
lint / linting (push) Waiting to run

There's no need for a `Mutex` in `StatefulIocaine`, so drop it - keep
only `Arc`.

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2025-02-04 01:43:04 +01:00
parent a0410a528d
commit 0b76a1633e
No known key found for this signature in database

View file

@ -10,14 +10,14 @@ use axum::{
routing::get, routing::get,
Router, Router,
}; };
use std::sync::{Arc, Mutex}; use std::sync::Arc;
use crate::{ use crate::{
assembled_statistical_sequences::AssembledStatisticalSequences, config::Config, assembled_statistical_sequences::AssembledStatisticalSequences, config::Config,
garglebargle::GargleBargle, wurstsalat_generator_pro::WurstsalatGeneratorPro, garglebargle::GargleBargle, wurstsalat_generator_pro::WurstsalatGeneratorPro,
}; };
type StatefulIocaine = Arc<Mutex<Iocaine>>; type StatefulIocaine = Arc<Iocaine>;
#[derive(Debug)] #[derive(Debug)]
pub struct Iocaine { pub struct Iocaine {
@ -46,7 +46,7 @@ impl Iocaine {
pub async fn run(self) -> std::result::Result<(), std::io::Error> { pub async fn run(self) -> std::result::Result<(), std::io::Error> {
let bind = &self.config.server.bind.clone(); 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() let app = Router::new()
.route("/", get(poison_root)) .route("/", get(poison_root))
.route("/{*path}", get(poison_path)) .route("/{*path}", get(poison_path))
@ -87,11 +87,7 @@ fn poison(iocaine: &StatefulIocaine, headers: axum::http::HeaderMap, path: &str)
.to_str() .to_str()
.unwrap(); .unwrap();
Html(AssembledStatisticalSequences::generate( Html(AssembledStatisticalSequences::generate(iocaine, host, path))
&iocaine.lock().unwrap(),
host,
path,
))
} }
async fn poison_root( async fn poison_root(