refactor: Replace std Mutex with parking_lot

This commit is contained in:
Jade Ellis 2025-07-19 20:36:27 +01:00
commit 30a8c06fd9
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
12 changed files with 44 additions and 59 deletions

View file

@ -1,31 +1,31 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;
use super::{
super::{Level, fmt},
Closure, Data,
};
use crate::Result;
use crate::{Result, SyncMutex};
pub fn fmt_html<S>(out: Arc<Mutex<S>>) -> Box<Closure>
pub fn fmt_html<S>(out: Arc<SyncMutex<S>>) -> Box<Closure>
where
S: std::fmt::Write + Send + 'static,
{
fmt(fmt::html, out)
}
pub fn fmt_markdown<S>(out: Arc<Mutex<S>>) -> Box<Closure>
pub fn fmt_markdown<S>(out: Arc<SyncMutex<S>>) -> Box<Closure>
where
S: std::fmt::Write + Send + 'static,
{
fmt(fmt::markdown, out)
}
pub fn fmt<F, S>(fun: F, out: Arc<Mutex<S>>) -> Box<Closure>
pub fn fmt<F, S>(fun: F, out: Arc<SyncMutex<S>>) -> Box<Closure>
where
F: Fn(&mut S, &Level, &str, &str) -> Result<()> + Send + Sync + Copy + 'static,
S: std::fmt::Write + Send + 'static,
{
Box::new(move |data| call(fun, &mut *out.lock().expect("locked"), &data))
Box::new(move |data| call(fun, &mut *out.lock(), &data))
}
fn call<F, S>(fun: F, out: &mut S, data: &Data<'_>)