88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- //! This mdoule defines types which are thread safe if cfg!(parallel_queries) is true.
11+ //! This module defines types which are thread safe if cfg!(parallel_queries) is true.
1212//!
1313//! `Lrc` is an alias of either Rc or Arc.
1414//!
@@ -40,6 +40,29 @@ use std;
4040use std:: ops:: { Deref , DerefMut } ;
4141use owning_ref:: { Erased , OwningRef } ;
4242
43+ pub fn serial_join < A , B , RA , RB > ( oper_a : A , oper_b : B ) -> ( RA , RB )
44+ where A : FnOnce ( ) -> RA ,
45+ B : FnOnce ( ) -> RB
46+ {
47+ ( oper_a ( ) , oper_b ( ) )
48+ }
49+
50+ pub struct SerialScope ;
51+
52+ impl SerialScope {
53+ pub fn spawn < F > ( & self , f : F )
54+ where F : FnOnce ( & SerialScope )
55+ {
56+ f ( self )
57+ }
58+ }
59+
60+ pub fn serial_scope < F , R > ( f : F ) -> R
61+ where F : FnOnce ( & SerialScope ) -> R
62+ {
63+ f ( & SerialScope )
64+ }
65+
4366cfg_if ! {
4467 if #[ cfg( not( parallel_queries) ) ] {
4568 pub auto trait Send { }
@@ -55,9 +78,19 @@ cfg_if! {
5578 }
5679 }
5780
81+ pub use self :: serial_join as join;
82+ pub use self :: serial_scope as scope;
83+
84+ pub use std:: iter:: Iterator as ParallelIterator ;
85+
86+ pub fn par_iter<T : IntoIterator >( t: T ) -> T :: IntoIter {
87+ t. into_iter( )
88+ }
89+
5890 pub type MetadataRef = OwningRef <Box <Erased >, [ u8 ] >;
5991
6092 pub use std:: rc:: Rc as Lrc ;
93+ pub use std:: rc:: Weak as Weak ;
6194 pub use std:: cell:: Ref as ReadGuard ;
6295 pub use std:: cell:: RefMut as WriteGuard ;
6396 pub use std:: cell:: RefMut as LockGuard ;
@@ -160,13 +193,22 @@ cfg_if! {
160193 pub use parking_lot:: MutexGuard as LockGuard ;
161194
162195 pub use std:: sync:: Arc as Lrc ;
196+ pub use std:: sync:: Weak as Weak ;
163197
164198 pub use self :: Lock as MTLock ;
165199
166200 use parking_lot:: Mutex as InnerLock ;
167201 use parking_lot:: RwLock as InnerRwLock ;
168202
169203 use std:: thread;
204+ pub use rayon:: { join, scope} ;
205+
206+ pub use rayon:: iter:: ParallelIterator ;
207+ use rayon:: iter:: IntoParallelIterator ;
208+
209+ pub fn par_iter<T : IntoParallelIterator >( t: T ) -> T :: Iter {
210+ t. into_par_iter( )
211+ }
170212
171213 pub type MetadataRef = OwningRef <Box <Erased + Send + Sync >, [ u8 ] >;
172214
0 commit comments