mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
chore: fmt
This commit is contained in:
parent
864344addb
commit
998bcf606a
1 changed files with 5 additions and 6 deletions
|
@ -31,7 +31,6 @@ pub struct Storage<DB: HasJars> {
|
|||
/// The runtime for this particular salsa database handle.
|
||||
/// Each handle gets its own runtime, but the runtimes have shared state between them.
|
||||
runtime: Runtime,
|
||||
|
||||
}
|
||||
|
||||
/// Data shared between all threads.
|
||||
|
@ -51,7 +50,7 @@ struct Shared<DB: HasJars> {
|
|||
cvar: Arc<Condvar>,
|
||||
|
||||
/// 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
|
||||
|
@ -66,7 +65,7 @@ where
|
|||
shared: Shared {
|
||||
jars: Some(Arc::from(jars)),
|
||||
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),
|
||||
runtime: Runtime::default(),
|
||||
|
@ -141,7 +140,7 @@ where
|
|||
self.runtime.set_cancellation_flag();
|
||||
|
||||
// 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 Arc::get_mut(self.shared.jars.as_mut().unwrap()).is_some() {
|
||||
return;
|
||||
|
@ -169,7 +168,7 @@ where
|
|||
Self {
|
||||
jars: self.jars.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) {
|
||||
// Drop the Arc reference before the cvar is notified,
|
||||
// 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());
|
||||
self.shared.cvar.notify_all();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue