11//! This module defines types which are thread safe if cfg!(parallel_compiler) is true.
22//!
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 .
44//!
55//! `Lock` is a mutex.
66//! It internally uses `parking_lot::Mutex` if cfg!(parallel_compiler) is true,
1212//!
1313//! `MTLock` is a mutex which disappears if cfg!(parallel_compiler) is false.
1414//!
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.
1616//!
1717//! `rustc_erase_owner!` erases a OwningRef owner into Erased or Erased + Send + Sync
1818//! depending on the value of cfg!(parallel_compiler).
@@ -23,29 +23,6 @@ use std::marker::PhantomData;
2323use std:: ops:: { Deref , DerefMut } ;
2424use crate :: owning_ref:: { Erased , OwningRef } ;
2525
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-
4926pub use std:: sync:: atomic:: Ordering :: SeqCst ;
5027pub use std:: sync:: atomic:: Ordering ;
5128
@@ -176,8 +153,28 @@ cfg_if! {
176153 pub type AtomicU32 = Atomic <u32 >;
177154 pub type AtomicU64 = Atomic <u64 >;
178155
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+ }
181178
182179 #[ macro_export]
183180 macro_rules! parallel {
0 commit comments