chore: fmt

This commit is contained in:
Mona Lisa 2024-03-15 23:01:30 +08:00
parent 864344addb
commit 998bcf606a

View file

@ -31,7 +31,6 @@ pub struct Storage<DB: HasJars> {
/// The runtime for this particular salsa database handle. /// The runtime for this particular salsa database handle.
/// Each handle gets its own runtime, but the runtimes have shared state between them. /// Each handle gets its own runtime, but the runtimes have shared state between them.
runtime: Runtime, runtime: Runtime,
} }
/// Data shared between all threads. /// Data shared between all threads.
@ -51,7 +50,7 @@ struct Shared<DB: HasJars> {
cvar: Arc<Condvar>, cvar: Arc<Condvar>,
/// Mutex that is used to protect the `jars` field when waiting for snapshots to be dropped. /// Mutex that is used to protect the `jars` field when waiting for snapshots to be dropped.
noti_lock:Arc< parking_lot::Mutex<()>> noti_lock: Arc<parking_lot::Mutex<()>>,
} }
// ANCHOR: default // ANCHOR: default
@ -66,7 +65,7 @@ where
shared: Shared { shared: Shared {
jars: Some(Arc::from(jars)), jars: Some(Arc::from(jars)),
cvar: Arc::new(Default::default()), cvar: Arc::new(Default::default()),
noti_lock:Arc::new( parking_lot::Mutex::new(())) noti_lock: Arc::new(parking_lot::Mutex::new(())),
}, },
routes: Arc::new(routes), routes: Arc::new(routes),
runtime: Runtime::default(), runtime: Runtime::default(),
@ -141,7 +140,7 @@ where
self.runtime.set_cancellation_flag(); self.runtime.set_cancellation_flag();
// jars need to be protected by a lock to avoid deadlocks. // jars need to be protected by a lock to avoid deadlocks.
let mut guard =self.shared.noti_lock.lock(); let mut guard = self.shared.noti_lock.lock();
// If we have unique access to the jars, we are done. // If we have unique access to the jars, we are done.
if Arc::get_mut(self.shared.jars.as_mut().unwrap()).is_some() { if Arc::get_mut(self.shared.jars.as_mut().unwrap()).is_some() {
return; return;
@ -169,7 +168,7 @@ where
Self { Self {
jars: self.jars.clone(), jars: self.jars.clone(),
cvar: self.cvar.clone(), cvar: self.cvar.clone(),
noti_lock: self.noti_lock.clone() noti_lock: self.noti_lock.clone(),
} }
} }
} }
@ -181,7 +180,7 @@ where
fn drop(&mut self) { fn drop(&mut self) {
// Drop the Arc reference before the cvar is notified, // Drop the Arc reference before the cvar is notified,
// since other threads are sleeping, waiting for it to reach 1. // since other threads are sleeping, waiting for it to reach 1.
let _guard =self.shared.noti_lock.lock(); let _guard = self.shared.noti_lock.lock();
drop(self.shared.jars.take()); drop(self.shared.jars.take());
self.shared.cvar.notify_all(); self.shared.cvar.notify_all();
} }