@@ -111,11 +111,7 @@ pub use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize};
111111pub use std:: sync:: { OnceLock , Weak } ;
112112
113113pub use mode:: { is_dyn_thread_safe, set_dyn_thread_safe_mode} ;
114- pub use parking_lot:: {
115- MappedMutexGuard as MappedLockGuard , MappedRwLockReadGuard as MappedReadGuard ,
116- MappedRwLockWriteGuard as MappedWriteGuard , RwLockReadGuard as ReadGuard ,
117- RwLockWriteGuard as WriteGuard ,
118- } ;
114+ pub use parking_lot:: MappedMutexGuard as MappedLockGuard ;
119115#[ cfg( not( target_has_atomic = "64" ) ) ]
120116pub use portable_atomic:: AtomicU64 ;
121117
@@ -151,12 +147,6 @@ impl<T> MTLock<T> {
151147 }
152148}
153149
154- use parking_lot:: RwLock as InnerRwLock ;
155-
156- /// This makes locks panic if they are already held.
157- /// It is only useful when you are running in a single thread
158- const ERROR_CHECKING : bool = false ;
159-
160150pub type MTLockRef < ' a , T > = LRef < ' a , MTLock < T > > ;
161151
162152#[ derive( Default ) ]
@@ -175,57 +165,7 @@ impl<K: Eq + Hash, V: Eq, S: BuildHasher> HashMapExt<K, V> for HashMap<K, V, S>
175165 }
176166}
177167
178- #[ derive( Debug , Default ) ]
179- pub struct RwLock < T > ( InnerRwLock < T > ) ;
180-
181- impl < T > RwLock < T > {
182- #[ inline( always) ]
183- pub fn new ( inner : T ) -> Self {
184- RwLock ( InnerRwLock :: new ( inner) )
185- }
186-
187- #[ inline( always) ]
188- pub fn into_inner ( self ) -> T {
189- self . 0 . into_inner ( )
190- }
191-
192- #[ inline( always) ]
193- pub fn get_mut ( & mut self ) -> & mut T {
194- self . 0 . get_mut ( )
195- }
196-
197- #[ inline( always) ]
198- pub fn read ( & self ) -> ReadGuard < ' _ , T > {
199- if ERROR_CHECKING {
200- self . 0 . try_read ( ) . expect ( "lock was already held" )
201- } else {
202- self . 0 . read ( )
203- }
204- }
205-
206- #[ inline( always) ]
207- pub fn try_write ( & self ) -> Result < WriteGuard < ' _ , T > , ( ) > {
208- self . 0 . try_write ( ) . ok_or ( ( ) )
209- }
210-
211- #[ inline( always) ]
212- pub fn write ( & self ) -> WriteGuard < ' _ , T > {
213- if ERROR_CHECKING {
214- self . 0 . try_write ( ) . expect ( "lock was already held" )
215- } else {
216- self . 0 . write ( )
217- }
218- }
219-
220- #[ inline( always) ]
221- #[ track_caller]
222- pub fn borrow ( & self ) -> ReadGuard < ' _ , T > {
223- self . read ( )
224- }
225-
226- #[ inline( always) ]
227- #[ track_caller]
228- pub fn borrow_mut ( & self ) -> WriteGuard < ' _ , T > {
229- self . write ( )
230- }
231- }
168+ mod rwlock;
169+ pub use rwlock:: {
170+ MappedReadGuard , MappedWriteGuard , ReadError , ReadGuard , RwLock , WriteError , WriteGuard ,
171+ } ;
0 commit comments