X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fsync%2Fnostd_sync.rs;h=858f60db5b5b46a5bb703f2d454d8d2b2c1f2934;hb=0b1a64f12d3dcad46110413cab0cbdfe73979702;hp=e17aa6ab15faa5dc33b66dbc1b80ab79fd36cb18;hpb=e954ee8256a70ee917135f4c03c8726bf305c2fc;p=rust-lightning diff --git a/lightning/src/sync/nostd_sync.rs b/lightning/src/sync/nostd_sync.rs index e17aa6ab..858f60db 100644 --- a/lightning/src/sync/nostd_sync.rs +++ b/lightning/src/sync/nostd_sync.rs @@ -62,12 +62,15 @@ impl Mutex { } } -impl LockTestExt for Mutex { +impl<'a, T: 'a> LockTestExt<'a> for Mutex { #[inline] fn held_by_thread(&self) -> LockHeldState { if self.lock().is_err() { return LockHeldState::HeldByThread; } else { return LockHeldState::NotHeldByThread; } } + type ExclLock = MutexGuard<'a, T>; + #[inline] + fn unsafe_well_ordered_double_lock_self(&'a self) -> MutexGuard { self.lock().unwrap() } } pub struct RwLock { @@ -125,12 +128,15 @@ impl RwLock { } } -impl LockTestExt for RwLock { +impl<'a, T: 'a> LockTestExt<'a> for RwLock { #[inline] fn held_by_thread(&self) -> LockHeldState { if self.write().is_err() { return LockHeldState::HeldByThread; } else { return LockHeldState::NotHeldByThread; } } + type ExclLock = RwLockWriteGuard<'a, T>; + #[inline] + fn unsafe_well_ordered_double_lock_self(&'a self) -> RwLockWriteGuard { self.write().unwrap() } } pub type FairRwLock = RwLock;