Remove try_lock from StorageHandle.

This commit is contained in:
Nick Mathewson 2021-10-20 09:42:34 -04:00
parent 7b6ed9dab6
commit fe85f44fd0
2 changed files with 2 additions and 8 deletions

View File

@ -22,9 +22,6 @@ pub trait StorageHandle<T: Serialize + DeserializeOwned> {
/// Return true if we have the lock; see [`StateMgr::can_store`].
fn can_store(&self) -> bool;
/// Try to acquire the lock; see [`StateMgr::can_store`].
fn try_lock(&self) -> Result<bool>;
}
/// Type wrapper for a reference-counted `dyn` [`StorageHandle`].
@ -69,9 +66,6 @@ where
fn can_store(&self) -> bool {
self.mgr.can_store()
}
fn try_lock(&self) -> Result<bool> {
Ok(self.mgr.try_lock()?.held())
}
}
impl<M, T> StorageHandleImpl<M, T>

View File

@ -176,7 +176,7 @@ mod test {
let h1: DynStorageHandle<Ex1> = mgr.clone().create_handle("foo");
let h2: DynStorageHandle<Ex2> = mgr.clone().create_handle("bar");
let h3: DynStorageHandle<Ex2> = mgr.create_handle("baz");
let h3: DynStorageHandle<Ex2> = mgr.clone().create_handle("baz");
let v1 = Ex1 { v1: 1, v2: 2 };
let s1 = Ex2 {
@ -189,7 +189,7 @@ mod test {
};
assert!(matches!(h1.store(&v1), Err(Error::NoLock)));
assert!(h1.try_lock().unwrap());
assert!(mgr.try_lock().unwrap().held());
assert!(h1.can_store());
assert!(h1.store(&v1).is_ok());