mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 02:11:54 +00:00
try-lock
This commit is contained in:
@@ -45,11 +45,11 @@ impl Store {
|
|||||||
let mut lock = OPEN_STORES.lock().await;
|
let mut lock = OPEN_STORES.lock().await;
|
||||||
(
|
(
|
||||||
if let Some(open) = lock.get(&path) {
|
if let Some(open) = lock.get(&path) {
|
||||||
open.clone().lock_owned().await
|
open.clone().try_lock_owned()?
|
||||||
} else {
|
} else {
|
||||||
let tex = Arc::new(Mutex::new(()));
|
let tex = Arc::new(Mutex::new(()));
|
||||||
lock.insert(path.clone(), tex.clone());
|
lock.insert(path.clone(), tex.clone());
|
||||||
tex.lock_owned().await
|
tex.try_lock_owned()?
|
||||||
},
|
},
|
||||||
path,
|
path,
|
||||||
)
|
)
|
||||||
@@ -69,7 +69,7 @@ impl Store {
|
|||||||
.truncate(false)
|
.truncate(false)
|
||||||
.open(&path)?,
|
.open(&path)?,
|
||||||
fd_lock_rs::LockType::Exclusive,
|
fd_lock_rs::LockType::Exclusive,
|
||||||
true,
|
false,
|
||||||
)?;
|
)?;
|
||||||
let mut stream =
|
let mut stream =
|
||||||
serde_cbor::StreamDeserializer::new(serde_cbor::de::IoRead::new(&mut *f));
|
serde_cbor::StreamDeserializer::new(serde_cbor::de::IoRead::new(&mut *f));
|
||||||
|
|||||||
Reference in New Issue
Block a user