X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fsync%2Fmod.rs;h=50ef40e295f50d0a0d9095a0f3dfe4c73916a340;hb=9c08fbd435b097c0aeec2843d8b4a6fdec06a8f0;hp=f5755fc1017be1f282c830cbaad12dd510bce88f;hpb=558bfa3fb3789d7d2586fef11d62367c174f370f;p=rust-lightning diff --git a/lightning/src/sync/mod.rs b/lightning/src/sync/mod.rs index f5755fc1..50ef40e2 100644 --- a/lightning/src/sync/mod.rs +++ b/lightning/src/sync/mod.rs @@ -1,12 +1,41 @@ +#[allow(dead_code)] // Depending on the compilation flags some variants are never used +#[derive(Debug, PartialEq, Eq)] +pub(crate) enum LockHeldState { + HeldByThread, + NotHeldByThread, + #[cfg(any(feature = "_bench_unstable", not(test)))] + Unsupported, +} + +pub(crate) trait LockTestExt { + fn held_by_thread(&self) -> LockHeldState; +} + #[cfg(all(feature = "std", not(feature = "_bench_unstable"), test))] mod debug_sync; #[cfg(all(feature = "std", not(feature = "_bench_unstable"), test))] pub use debug_sync::*; +#[cfg(all(feature = "std", not(feature = "_bench_unstable"), test))] +// Note that to make debug_sync's regex work this must not contain `debug_string` in the module name +mod test_lockorder_checks; #[cfg(all(feature = "std", any(feature = "_bench_unstable", not(test))))] -pub use ::std::sync::{Arc, Mutex, Condvar, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard}; +pub(crate) mod fairrwlock; +#[cfg(all(feature = "std", any(feature = "_bench_unstable", not(test))))] +pub use {std::sync::{Arc, Mutex, Condvar, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard}, fairrwlock::FairRwLock}; + #[cfg(all(feature = "std", any(feature = "_bench_unstable", not(test))))] -pub use crate::util::fairrwlock::FairRwLock; +mod ext_impl { + use super::*; + impl LockTestExt for Mutex { + #[inline] + fn held_by_thread(&self) -> LockHeldState { LockHeldState::Unsupported } + } + impl LockTestExt for RwLock { + #[inline] + fn held_by_thread(&self) -> LockHeldState { LockHeldState::Unsupported } + } +} #[cfg(not(feature = "std"))] mod nostd_sync;