98
98
RA : Send ,
99
99
RB : Send ,
100
100
{
101
- join_context ( |_| oper_a ( ) , |_| oper_b ( ) )
101
+ #[ inline]
102
+ fn call < R > ( f : impl FnOnce ( ) -> R ) -> impl FnOnce ( FnContext ) -> R {
103
+ move |_| f ( )
104
+ }
105
+
106
+ join_context ( call ( oper_a) , call ( oper_b) )
102
107
}
103
108
104
109
/// Identical to `join`, except that the closures have a parameter
@@ -115,22 +120,30 @@ where
115
120
RA : Send ,
116
121
RB : Send ,
117
122
{
123
+ #[ inline]
124
+ fn call_a < R > ( f : impl FnOnce ( FnContext ) -> R , injected : bool ) -> impl FnOnce ( ) -> R {
125
+ move || f ( FnContext :: new ( injected) )
126
+ }
127
+
128
+ #[ inline]
129
+ fn call_b < R > ( f : impl FnOnce ( FnContext ) -> R ) -> impl FnOnce ( bool ) -> R {
130
+ move |migrated| f ( FnContext :: new ( migrated) )
131
+ }
132
+
118
133
registry:: in_worker ( |worker_thread, injected| unsafe {
119
134
log ! ( Join {
120
135
worker: worker_thread. index( )
121
136
} ) ;
122
137
123
- let latch = SpinLatch :: new ( ) ;
124
-
125
138
// Create virtual wrapper for task b; this all has to be
126
139
// done here so that the stack frame can keep it all live
127
140
// long enough.
128
- let job_b = StackJob :: new ( |migrated| oper_b ( FnContext :: new ( migrated ) ) , latch ) ;
141
+ let job_b = StackJob :: new ( call_b ( oper_b ) , SpinLatch :: new ( ) ) ;
129
142
let job_b_ref = job_b. as_job_ref ( ) ;
130
143
worker_thread. push ( job_b_ref) ;
131
144
132
145
// Execute task a; hopefully b gets stolen in the meantime.
133
- let status_a = unwind:: halt_unwinding ( move || oper_a ( FnContext :: new ( injected) ) ) ;
146
+ let status_a = unwind:: halt_unwinding ( call_a ( oper_a , injected) ) ;
134
147
let result_a = match status_a {
135
148
Ok ( v) => v,
136
149
Err ( err) => join_recover_from_panic ( worker_thread, & job_b. latch , err) ,
0 commit comments