1
1
//! This module defines types which are thread safe if cfg!(parallel_compiler) is true.
2
2
//!
3
- //! `Lrc` is an alias of either Rc or Arc .
3
+ //! `Lrc` is an alias of `Arc` if cfg!(parallel_compiler) is true, `Rc` otherwise .
4
4
//!
5
5
//! `Lock` is a mutex.
6
6
//! It internally uses `parking_lot::Mutex` if cfg!(parallel_compiler) is true,
12
12
//!
13
13
//! `MTLock` is a mutex which disappears if cfg!(parallel_compiler) is false.
14
14
//!
15
- //! `MTRef` is a immutable reference if cfg!(parallel_compiler), and an mutable reference otherwise.
15
+ //! `MTRef` is an immutable reference if cfg!(parallel_compiler), and a mutable reference otherwise.
16
16
//!
17
17
//! `rustc_erase_owner!` erases a OwningRef owner into Erased or Erased + Send + Sync
18
18
//! depending on the value of cfg!(parallel_compiler).
@@ -23,29 +23,6 @@ use std::marker::PhantomData;
23
23
use std:: ops:: { Deref , DerefMut } ;
24
24
use crate :: owning_ref:: { Erased , OwningRef } ;
25
25
26
- pub fn serial_join < A , B , RA , RB > ( oper_a : A , oper_b : B ) -> ( RA , RB )
27
- where A : FnOnce ( ) -> RA ,
28
- B : FnOnce ( ) -> RB
29
- {
30
- ( oper_a ( ) , oper_b ( ) )
31
- }
32
-
33
- pub struct SerialScope ;
34
-
35
- impl SerialScope {
36
- pub fn spawn < F > ( & self , f : F )
37
- where F : FnOnce ( & SerialScope )
38
- {
39
- f ( self )
40
- }
41
- }
42
-
43
- pub fn serial_scope < F , R > ( f : F ) -> R
44
- where F : FnOnce ( & SerialScope ) -> R
45
- {
46
- f ( & SerialScope )
47
- }
48
-
49
26
pub use std:: sync:: atomic:: Ordering :: SeqCst ;
50
27
pub use std:: sync:: atomic:: Ordering ;
51
28
@@ -176,8 +153,28 @@ cfg_if! {
176
153
pub type AtomicU32 = Atomic <u32 >;
177
154
pub type AtomicU64 = Atomic <u64 >;
178
155
179
- pub use self :: serial_join as join;
180
- pub use self :: serial_scope as scope;
156
+ pub fn join<A , B , RA , RB >( oper_a: A , oper_b: B ) -> ( RA , RB )
157
+ where A : FnOnce ( ) -> RA ,
158
+ B : FnOnce ( ) -> RB
159
+ {
160
+ ( oper_a( ) , oper_b( ) )
161
+ }
162
+
163
+ pub struct SerialScope ;
164
+
165
+ impl SerialScope {
166
+ pub fn spawn<F >( & self , f: F )
167
+ where F : FnOnce ( & SerialScope )
168
+ {
169
+ f( self )
170
+ }
171
+ }
172
+
173
+ pub fn scope<F , R >( f: F ) -> R
174
+ where F : FnOnce ( & SerialScope ) -> R
175
+ {
176
+ f( & SerialScope )
177
+ }
181
178
182
179
#[ macro_export]
183
180
macro_rules! parallel {
0 commit comments