Skip to content

Commit efc0244

Browse files
committed
Make the no-std RwLockGuard try_lock actually try
There doesn't appear to be any reason to have `try_lock` fail, and future work shouldn't need to check for std to use `try_lock`.
1 parent d8a20ed commit efc0244

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lightning/src/sync.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ impl<T> RwLock<T> {
109109
}
110110

111111
pub fn try_write<'a>(&'a self) -> LockResult<RwLockWriteGuard<'a, T>> {
112-
// There is no try, grasshopper - only used for tests and expected to fail
113-
Err(())
112+
match self.inner.try_borrow_mut() {
113+
Ok(lock) => Ok(RwLockWriteGuard { lock }),
114+
Err(_) => Err(())
115+
}
114116
}
115117
}
116118

0 commit comments

Comments
 (0)