projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d8a20ed
)
Make the no-std `RwLockGuard` `try_lock` actually try
2023-01-nostd-try-lock
author
Matt Corallo
<git@bluematt.me>
Sat, 7 Jan 2023 20:11:05 +0000
(20:11 +0000)
committer
Matt Corallo
<git@bluematt.me>
Sat, 7 Jan 2023 22:43:09 +0000
(22:43 +0000)
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`.
lightning/src/sync.rs
patch
|
blob
|
history
diff --git
a/lightning/src/sync.rs
b/lightning/src/sync.rs
index 482759b8ca88b626fd0585f0e73f84d33a7d967c..caf88a7cc04a8617a86e63988a7cc7a291fe96bc 100644
(file)
--- a/
lightning/src/sync.rs
+++ b/
lightning/src/sync.rs
@@
-109,8
+109,10
@@
impl<T> RwLock<T> {
}
pub fn try_write<'a>(&'a self) -> LockResult<RwLockWriteGuard<'a, T>> {
- // There is no try, grasshopper - only used for tests and expected to fail
- Err(())
+ match self.inner.try_borrow_mut() {
+ Ok(lock) => Ok(RwLockWriteGuard { lock }),
+ Err(_) => Err(())
+ }
}
}