mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-11 07:33:01 +02:00
refactor: Replace std Mutex with parking_lot
This commit is contained in:
parent
0631094350
commit
30a8c06fd9
12 changed files with 44 additions and 59 deletions
|
@ -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<'_>)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue