From: Viktor Tigerström <11711198+ViktorTigerstrom@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:40:54 +0000 (+0100) Subject: Add `try_write` function to `FairRwLock` X-Git-Tag: v0.0.114-beta~67^2~14 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=4207eab59db92160c0ee274dd16c8b3a79aacc6c;p=rust-lightning Add `try_write` function to `FairRwLock` --- diff --git a/lightning/src/util/fairrwlock.rs b/lightning/src/util/fairrwlock.rs index c9b3866be..5715a8cf6 100644 --- a/lightning/src/util/fairrwlock.rs +++ b/lightning/src/util/fairrwlock.rs @@ -1,4 +1,4 @@ -use std::sync::{LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard}; +use std::sync::{LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard, TryLockResult}; use std::sync::atomic::{AtomicUsize, Ordering}; /// Rust libstd's RwLock does not provide any fairness guarantees (and, in fact, when used on @@ -43,4 +43,8 @@ impl FairRwLock { // codebase. self.lock.read() } + + pub fn try_write(&self) -> TryLockResult> { + self.lock.try_write() + } }