6666 let oper_a = FromDyn :: from ( oper_a) ;
6767 let oper_b = FromDyn :: from ( oper_b) ;
6868 let ( a, b) = parallel_guard ( |guard| {
69- raw_branched_join (
70- move || guard. run ( move || FromDyn :: from ( oper_a. into_inner ( ) ( ) ) ) ,
71- move || guard. run ( move || FromDyn :: from ( oper_b. into_inner ( ) ( ) ) ) ,
69+ let task_a = move || guard. run ( move || FromDyn :: from ( oper_a. into_inner ( ) ( ) ) ) ;
70+ let task_b = move || guard. run ( move || FromDyn :: from ( oper_b. into_inner ( ) ( ) ) ) ;
71+ rustc_thread_pool:: join (
72+ || branch_context ( 0 , 2 , task_a) ,
73+ || branch_context ( 1 , 2 , task_b) ,
7274 )
7375 } ) ;
7476 ( a. unwrap ( ) . into_inner ( ) , b. unwrap ( ) . into_inner ( ) )
@@ -197,15 +199,11 @@ pub fn par_map<I: DynSend, T: IntoIterator<Item = I>, R: DynSend, C: FromIterato
197199 } )
198200}
199201
200- fn raw_branched_join < A , B , RA : Send , RB : Send > ( oper_a : A , oper_b : B ) -> ( RA , RB )
201- where
202- A : FnOnce ( ) -> RA + Send ,
203- B : FnOnce ( ) -> RB + Send ,
204- {
205- rustc_thread_pool:: join ( || branch_context ( 0 , 2 , oper_a) , || branch_context ( 1 , 2 , oper_b) )
206- }
207-
208- fn branch_context < F , R > ( branch_num : u64 , branch_space : u64 , f : F ) -> R
202+ /// Append `i`-th branch out of `n` branches to `icx.query.branch` to track inside of
203+ /// which parallel task every query call is performed.
204+ ///
205+ /// See [`rustc_data_structures::tree_node_index::TreeNodeIndex`].
206+ fn branch_context < F , R > ( i : u64 , n : u64 , f : F ) -> R
209207where
210208 F : FnOnce ( ) -> R ,
211209{
@@ -214,7 +212,7 @@ where
214212 && let Some ( QueryInclusion { id, branch } ) = icx. query
215213 {
216214 let icx = tls:: ImplicitCtxt {
217- query : Some ( QueryInclusion { id, branch : branch. branch ( branch_num , branch_space ) } ) ,
215+ query : Some ( QueryInclusion { id, branch : branch. branch ( i , n ) } ) ,
218216 ..* icx
219217 } ;
220218 tls:: enter_context ( & icx, f)
0 commit comments