@@ -16,14 +16,14 @@ use std::sync::Arc;
16
16
use std:: sync:: atomic:: { AtomicPtr , AtomicU8 , AtomicUsize , Ordering } ;
17
17
use std:: { cmp, fmt, mem} ;
18
18
19
- use parking_lot:: { Mutex , MutexGuard } ;
19
+ use parking_lot:: Mutex ;
20
20
21
21
use super :: collect:: { self , Pin , pin} ;
22
22
use super :: raw:: bitmask:: BitMask ;
23
23
use super :: raw:: imp:: Group ;
24
24
use super :: scopeguard:: guard;
25
25
use super :: util:: { cold_path, make_insert_hash} ;
26
- use crate :: sync:: { DynSend , DynSync } ;
26
+ use crate :: sync:: { DynSend , DynSync , Lock , LockGuard } ;
27
27
28
28
mod code;
29
29
mod tests;
@@ -137,7 +137,7 @@ pub struct Write<'a, K, V, S = DefaultHashBuilder> {
137
137
/// A handle to a [SyncTable] with write access protected by a lock.
138
138
pub struct LockedWrite < ' a , K , V , S = DefaultHashBuilder > {
139
139
table : Write < ' a , K , V , S > ,
140
- _guard : MutexGuard < ' a , ( ) > ,
140
+ _guard : LockGuard < ' a , ( ) > ,
141
141
}
142
142
143
143
impl < ' a , K , V , S > Deref for LockedWrite < ' a , K , V , S > {
@@ -167,7 +167,7 @@ pub struct SyncTable<K, V, S = DefaultHashBuilder> {
167
167
168
168
current : AtomicPtr < TableInfo > ,
169
169
170
- lock : Mutex < ( ) > ,
170
+ lock : Lock < ( ) > ,
171
171
172
172
old : UnsafeCell < Vec < Arc < DestroyTable < ( K , V ) > > > > ,
173
173
@@ -702,7 +702,7 @@ impl<K, V, S> SyncTable<K, V, S> {
702
702
) ,
703
703
old : UnsafeCell :: new ( Vec :: new ( ) ) ,
704
704
marker : PhantomData ,
705
- lock : Mutex :: new ( ( ) ) ,
705
+ lock : Lock :: new ( ( ) ) ,
706
706
}
707
707
}
708
708
@@ -714,7 +714,7 @@ impl<K, V, S> SyncTable<K, V, S> {
714
714
715
715
/// Gets a reference to the underlying mutex that protects writes.
716
716
#[ inline]
717
- pub fn mutex ( & self ) -> & Mutex < ( ) > {
717
+ pub fn mutex ( & self ) -> & Lock < ( ) > {
718
718
& self . lock
719
719
}
720
720
@@ -747,16 +747,16 @@ impl<K, V, S> SyncTable<K, V, S> {
747
747
pub fn lock ( & self ) -> LockedWrite < ' _ , K , V , S > {
748
748
LockedWrite { table : Write { table : self } , _guard : self . lock . lock ( ) }
749
749
}
750
+ /*
751
+ /// Creates a [LockedWrite] handle from a guard protecting the underlying mutex that protects writes.
752
+ #[inline]
753
+ pub fn lock_from_guard<'a>(&'a self, guard: LockGuard<'a, ()>) -> LockedWrite<'a, K, V, S> {
754
+ // Verify that we are target of the guard
755
+ assert_eq!(&self.lock as *const _, LockGuard::mutex(&guard) as *const _);
750
756
751
- /// Creates a [LockedWrite] handle from a guard protecting the underlying mutex that protects writes.
752
- #[ inline]
753
- pub fn lock_from_guard < ' a > ( & ' a self , guard : MutexGuard < ' a , ( ) > ) -> LockedWrite < ' a , K , V , S > {
754
- // Verify that we are target of the guard
755
- assert_eq ! ( & self . lock as * const _, MutexGuard :: mutex( & guard) as * const _) ;
756
-
757
- LockedWrite { table : Write { table : self } , _guard : guard }
758
- }
759
-
757
+ LockedWrite { table: Write { table: self }, _guard: guard }
758
+ }
759
+ */
760
760
#[ inline]
761
761
fn current ( & self ) -> TableRef < ( K , V ) > {
762
762
TableRef {
@@ -928,7 +928,7 @@ impl<K: Hash + Clone, V: Clone, S: Clone + BuildHasher> Clone for SyncTable<K, V
928
928
) ,
929
929
old : UnsafeCell :: new ( Vec :: new ( ) ) ,
930
930
marker : PhantomData ,
931
- lock : Mutex :: new ( ( ) ) ,
931
+ lock : Lock :: new ( ( ) ) ,
932
932
}
933
933
}
934
934
} )
0 commit comments