@@ -80,25 +80,40 @@ where
8080// -----------------------------------------------------------------------------
8181// Scope
8282
83- pub use forte:: Scope ;
83+ pub struct Scope < ' scope , ' env > {
84+ inner_scope : & ' scope forte:: Scope < ' scope , ' env > ,
85+ }
86+
87+ impl < ' scope , ' env > Scope < ' scope , ' env > {
88+ pub fn spawn < F > ( self , f : F )
89+ where
90+ F : FnOnce ( Scope < ' scope , ' env > ) + Send + ' scope ,
91+ {
92+ forte:: Worker :: with_current ( |worker| {
93+ let worker = worker. unwrap ( ) ;
94+ let inner_scope = self . inner_scope ;
95+ inner_scope. spawn_on ( worker, |_| f ( Scope { inner_scope } ) )
96+ } ) ;
97+ }
98+ }
8499
85100#[ inline( always) ]
86- pub fn scope < ' scope , OP , R > ( op : OP ) -> R
101+ pub fn scope < ' env , OP , R > ( op : OP ) -> R
87102where
88- OP : FnOnce ( & Scope < ' scope > ) -> R + Send ,
103+ OP : for < ' scope > FnOnce ( Scope < ' scope , ' env > ) -> R + Send ,
89104 R : Send ,
90105{
91106 ensure_started ( ) ;
92- forte:: scope ( op )
107+ forte:: scope ( |inner_scope| op ( Scope { inner_scope } ) )
93108}
94109
95110#[ inline( always) ]
96- pub fn in_place_scope < ' scope , OP , R > ( op : OP ) -> R
111+ pub fn in_place_scope < ' env , OP , R > ( op : OP ) -> R
97112where
98- OP : FnOnce ( & Scope < ' scope > ) -> R ,
113+ OP : for < ' scope > FnOnce ( Scope < ' scope , ' env > ) -> R ,
99114{
100115 ensure_started ( ) ;
101- forte:: scope ( op )
116+ forte:: scope ( |inner_scope| op ( Scope { inner_scope } ) )
102117}
103118
104119// -----------------------------------------------------------------------------
0 commit comments