From 6c96edee4cebbcfc18149240d5d9a77156ffd677 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Viktor=20Tigerstr=C3=B6m?= <11711198+ViktorTigerstrom@users.noreply.github.com> Date: Thu, 8 Dec 2022 22:40:54 +0100 Subject: [PATCH] Add `try_write` function to `FairRwLock` --- lightning/src/util/fairrwlock.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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() + } } -- 2.39.5