18
18
//!
19
19
//! | Type | Serial version | Parallel version |
20
20
//! | ----------------------- | ------------------- | ------------------------------- |
21
- //! |` Weak<T>` | `rc::Weak<T>` | `sync::Weak<T>` |
22
21
//! | `LRef<'a, T>` [^2] | `&'a mut T` | `&'a T` |
23
22
//! | | | |
24
- //! | `AtomicBool` | `Cell<bool>` | `atomic::AtomicBool` |
25
- //! | `AtomicU32` | `Cell<u32>` | `atomic::AtomicU32` |
26
- //! | `AtomicU64` | `Cell<u64>` | `atomic::AtomicU64` |
27
- //! | `AtomicUsize` | `Cell<usize>` | `atomic::AtomicUsize` |
28
- //! | | | |
29
23
//! | `Lock<T>` | `RefCell<T>` | `RefCell<T>` or |
30
24
//! | | | `parking_lot::Mutex<T>` |
31
25
//! | `RwLock<T>` | `RefCell<T>` | `parking_lot::RwLock<T>` |
@@ -103,18 +97,15 @@ mod mode {
103
97
104
98
// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
105
99
106
- pub use std:: marker :: { Send , Sync } ;
100
+ pub use std:: sync :: OnceLock ;
107
101
// Use portable AtomicU64 for targets without native 64-bit atomics
108
102
#[ cfg( target_has_atomic = "64" ) ]
109
103
pub use std:: sync:: atomic:: AtomicU64 ;
110
- pub use std:: sync:: atomic:: { AtomicBool , AtomicU32 , AtomicUsize } ;
111
- pub use std:: sync:: { OnceLock , Weak } ;
112
104
113
105
pub use mode:: { is_dyn_thread_safe, set_dyn_thread_safe_mode} ;
114
106
pub use parking_lot:: {
115
- MappedMutexGuard as MappedLockGuard , MappedRwLockReadGuard as MappedReadGuard ,
116
- MappedRwLockWriteGuard as MappedWriteGuard , RwLockReadGuard as ReadGuard ,
117
- RwLockWriteGuard as WriteGuard ,
107
+ MappedRwLockReadGuard as MappedReadGuard , MappedRwLockWriteGuard as MappedWriteGuard ,
108
+ RwLockReadGuard as ReadGuard , RwLockWriteGuard as WriteGuard ,
118
109
} ;
119
110
#[ cfg( not( target_has_atomic = "64" ) ) ]
120
111
pub use portable_atomic:: AtomicU64 ;
@@ -203,12 +194,6 @@ impl<T> RwLock<T> {
203
194
}
204
195
}
205
196
206
- #[ inline( always) ]
207
- #[ track_caller]
208
- pub fn with_read_lock < F : FnOnce ( & T ) -> R , R > ( & self , f : F ) -> R {
209
- f ( & * self . read ( ) )
210
- }
211
-
212
197
#[ inline( always) ]
213
198
pub fn try_write ( & self ) -> Result < WriteGuard < ' _ , T > , ( ) > {
214
199
self . 0 . try_write ( ) . ok_or ( ( ) )
@@ -223,12 +208,6 @@ impl<T> RwLock<T> {
223
208
}
224
209
}
225
210
226
- #[ inline( always) ]
227
- #[ track_caller]
228
- pub fn with_write_lock < F : FnOnce ( & mut T ) -> R , R > ( & self , f : F ) -> R {
229
- f ( & mut * self . write ( ) )
230
- }
231
-
232
211
#[ inline( always) ]
233
212
#[ track_caller]
234
213
pub fn borrow ( & self ) -> ReadGuard < ' _ , T > {
@@ -240,20 +219,4 @@ impl<T> RwLock<T> {
240
219
pub fn borrow_mut ( & self ) -> WriteGuard < ' _ , T > {
241
220
self . write ( )
242
221
}
243
-
244
- #[ inline( always) ]
245
- pub fn leak ( & self ) -> & T {
246
- let guard = self . read ( ) ;
247
- let ret = unsafe { & * ( & raw const * guard) } ;
248
- std:: mem:: forget ( guard) ;
249
- ret
250
- }
251
- }
252
-
253
- // FIXME: Probably a bad idea
254
- impl < T : Clone > Clone for RwLock < T > {
255
- #[ inline]
256
- fn clone ( & self ) -> Self {
257
- RwLock :: new ( self . borrow ( ) . clone ( ) )
258
- }
259
222
}
0 commit comments