Remove try_lock from StorageHandle.
This commit is contained in:
parent
7b6ed9dab6
commit
fe85f44fd0
|
@ -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>
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue