32
32
use std:: collections:: HashMap ;
33
33
use std:: hash:: { BuildHasher , Hash } ;
34
34
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
+ } ;
36
39
37
- mod lock;
40
+ pub use self :: atomic:: AtomicU64 ;
41
+ pub use self :: freeze:: { FreezeLock , FreezeReadGuard , FreezeWriteGuard } ;
38
42
#[ 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:: * ;
43
51
52
+ mod freeze;
53
+ mod lock;
44
54
mod 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
-
48
55
mod vec;
56
+ mod worker_local;
49
57
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
+ }
52
69
53
70
mod mode {
54
71
use std:: sync:: atomic:: { AtomicU8 , Ordering } ;
@@ -92,18 +109,6 @@ mod mode {
92
109
93
110
// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
94
111
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
-
107
112
#[ derive( Debug , Default ) ]
108
113
pub struct MTLock < T > ( Lock < T > ) ;
109
114
@@ -134,8 +139,6 @@ impl<T> MTLock<T> {
134
139
}
135
140
}
136
141
137
- use parking_lot:: RwLock as InnerRwLock ;
138
-
139
142
/// This makes locks panic if they are already held.
140
143
/// It is only useful when you are running in a single thread
141
144
const ERROR_CHECKING : bool = false ;
@@ -157,12 +160,12 @@ impl<K: Eq + Hash, V: Eq, S: BuildHasher> HashMapExt<K, V> for HashMap<K, V, S>
157
160
}
158
161
159
162
#[ derive( Debug , Default ) ]
160
- pub struct RwLock < T > ( InnerRwLock < T > ) ;
163
+ pub struct RwLock < T > ( parking_lot :: RwLock < T > ) ;
161
164
162
165
impl < T > RwLock < T > {
163
166
#[ inline( always) ]
164
167
pub fn new ( inner : T ) -> Self {
165
- RwLock ( InnerRwLock :: new ( inner) )
168
+ RwLock ( parking_lot :: RwLock :: new ( inner) )
166
169
}
167
170
168
171
#[ inline( always) ]
0 commit comments