3232use std:: collections:: HashMap ;
3333use std:: hash:: { BuildHasher , Hash } ;
3434
35- pub use crate :: marker:: * ;
35+ pub use parking_lot:: {
36+ MappedRwLockReadGuard as MappedReadGuard , MappedRwLockWriteGuard as MappedWriteGuard ,
37+ RwLockReadGuard as ReadGuard , RwLockWriteGuard as WriteGuard ,
38+ } ;
3639
37- mod lock;
40+ pub use self :: atomic:: AtomicU64 ;
41+ pub use self :: freeze:: { FreezeLock , FreezeReadGuard , FreezeWriteGuard } ;
3842#[ doc( no_inline) ]
39- pub use lock:: { Lock , LockGuard , Mode } ;
40-
41- mod worker_local;
42- pub use worker_local:: { Registry , WorkerLocal } ;
43+ pub use self :: lock:: { Lock , LockGuard , Mode } ;
44+ pub use self :: mode:: { is_dyn_thread_safe, set_dyn_thread_safe_mode} ;
45+ pub use self :: parallel:: {
46+ join, par_for_each_in, par_map, parallel_guard, scope, try_par_for_each_in,
47+ } ;
48+ pub use self :: vec:: { AppendOnlyIndexVec , AppendOnlyVec } ;
49+ pub use self :: worker_local:: { Registry , WorkerLocal } ;
50+ pub use crate :: marker:: * ;
4351
52+ mod freeze;
53+ mod lock;
4454mod parallel;
45- pub use parallel:: { join, par_for_each_in, par_map, parallel_guard, scope, try_par_for_each_in} ;
46- pub use vec:: { AppendOnlyIndexVec , AppendOnlyVec } ;
47-
4855mod vec;
56+ mod worker_local;
4957
50- mod freeze;
51- pub use freeze:: { FreezeLock , FreezeReadGuard , FreezeWriteGuard } ;
58+ /// Keep the conditional imports together in a submodule, so that import-sorting
59+ /// doesn't split them up.
60+ mod atomic {
61+ // Most hosts can just use a regular AtomicU64.
62+ #[ cfg( target_has_atomic = "64" ) ]
63+ pub use std:: sync:: atomic:: AtomicU64 ;
64+
65+ // Some 32-bit hosts don't have AtomicU64, so use a fallback.
66+ #[ cfg( not( target_has_atomic = "64" ) ) ]
67+ pub use portable_atomic:: AtomicU64 ;
68+ }
5269
5370mod mode {
5471 use std:: sync:: atomic:: { AtomicU8 , Ordering } ;
@@ -92,18 +109,6 @@ mod mode {
92109
93110// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
94111
95- // Use portable AtomicU64 for targets without native 64-bit atomics
96- #[ cfg( target_has_atomic = "64" ) ]
97- pub use std:: sync:: atomic:: AtomicU64 ;
98-
99- pub use mode:: { is_dyn_thread_safe, set_dyn_thread_safe_mode} ;
100- pub use parking_lot:: {
101- MappedRwLockReadGuard as MappedReadGuard , MappedRwLockWriteGuard as MappedWriteGuard ,
102- RwLockReadGuard as ReadGuard , RwLockWriteGuard as WriteGuard ,
103- } ;
104- #[ cfg( not( target_has_atomic = "64" ) ) ]
105- pub use portable_atomic:: AtomicU64 ;
106-
107112#[ derive( Debug , Default ) ]
108113pub struct MTLock < T > ( Lock < T > ) ;
109114
@@ -134,8 +139,6 @@ impl<T> MTLock<T> {
134139 }
135140}
136141
137- use parking_lot:: RwLock as InnerRwLock ;
138-
139142/// This makes locks panic if they are already held.
140143/// It is only useful when you are running in a single thread
141144const ERROR_CHECKING : bool = false ;
@@ -157,12 +160,12 @@ impl<K: Eq + Hash, V: Eq, S: BuildHasher> HashMapExt<K, V> for HashMap<K, V, S>
157160}
158161
159162#[ derive( Debug , Default ) ]
160- pub struct RwLock < T > ( InnerRwLock < T > ) ;
163+ pub struct RwLock < T > ( parking_lot :: RwLock < T > ) ;
161164
162165impl < T > RwLock < T > {
163166 #[ inline( always) ]
164167 pub fn new ( inner : T ) -> Self {
165- RwLock ( InnerRwLock :: new ( inner) )
168+ RwLock ( parking_lot :: RwLock :: new ( inner) )
166169 }
167170
168171 #[ inline( always) ]
0 commit comments