@@ -34,24 +34,23 @@ impl<'scope> ScopeBuilder<'scope> {
34
34
35
35
pub fn scope < OP , R > ( & ' scope mut self , op : OP ) -> R
36
36
where
37
- OP : FnOnce ( & ' scope Scope < ' scope > ) -> R + ' scope + Send ,
38
- R : Send ,
37
+ OP : FnOnce ( & ' scope Scope < ' scope > ) -> R + ' scope ,
39
38
{
40
- in_worker ( move |owner_thread , _| {
41
- unsafe {
42
- self . scope = Some ( Scope {
43
- owner_thread_index : owner_thread . index ( ) ,
44
- registry : owner_thread . registry ( ) . clone ( ) ,
45
- panic : AtomicPtr :: new ( ptr :: null_mut ( ) ) ,
46
- job_completed_latch : CountLatch :: new ( ) ,
47
- marker : PhantomData ,
48
- } ) ;
49
- let scope = self . scope . as_ref ( ) . unwrap ( ) ;
50
- let result = scope . execute_job_closure ( move |_| op ( scope ) ) ;
39
+ unsafe {
40
+ self . scope = Some ( Scope {
41
+ owner_thread_index : 0 ,
42
+ registry : Registry :: current ( ) ,
43
+ panic : AtomicPtr :: new ( ptr :: null_mut ( ) ) ,
44
+ job_completed_latch : CountLatch :: new ( ) ,
45
+ marker : PhantomData ,
46
+ } ) ;
47
+ let scope = self . scope . as_ref ( ) . unwrap ( ) ;
48
+ let result = scope. execute_job_closure ( move |_| op ( scope ) ) ;
49
+ in_worker ( move |owner_thread , _| {
51
50
scope. steal_till_jobs_complete ( owner_thread) ;
52
- result . unwrap ( ) // only None if `op` panicked, and that would have been propagated
53
- }
54
- } )
51
+ } ) ;
52
+ result . unwrap ( ) // only None if `op` panicked, and that would have been propagated
53
+ }
55
54
}
56
55
}
57
56
0 commit comments