Adapt intro node process_pending_htlcs test for non-intro nodes
[rust-lightning] / lightning / src / sync / fairrwlock.rs
index 5715a8cf646cd67e29b7aa5c21c8722d89a45964..23b8c23db282b20ad5c90d3fc937e367e6b6dac6 100644 (file)
@@ -1,5 +1,6 @@
 use std::sync::{LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard, TryLockResult};
 use std::sync::atomic::{AtomicUsize, Ordering};
+use super::{LockHeldState, LockTestExt};
 
 /// Rust libstd's RwLock does not provide any fairness guarantees (and, in fact, when used on
 /// Linux with pthreads under the hood, readers trivially and completely starve writers).
@@ -44,7 +45,21 @@ impl<T> FairRwLock<T> {
                self.lock.read()
        }
 
+       #[allow(dead_code)]
        pub fn try_write(&self) -> TryLockResult<RwLockWriteGuard<'_, T>> {
                self.lock.try_write()
        }
 }
+
+impl<'a, T: 'a> LockTestExt<'a> for FairRwLock<T> {
+       #[inline]
+       fn held_by_thread(&self) -> LockHeldState {
+               // fairrwlock is only built in non-test modes, so we should never support tests.
+               LockHeldState::Unsupported
+       }
+       type ExclLock = RwLockWriteGuard<'a, T>;
+       #[inline]
+       fn unsafe_well_ordered_double_lock_self(&'a self) -> RwLockWriteGuard<'a, T> {
+               self.write().unwrap()
+       }
+}