pub struct Scope<'scope> { /* private fields */ }
Expand description
An execution scope, represents a set of jobs running on a Pool.
§Understanding Scope lifetimes
Besides Scope<'static>
, all Scope
objects are accessed behind a
reference of the form &'scheduler Scope<'scope>
.
'scheduler
is the lifetime associated with the body of the
“scheduler” function (functions passed to zoom
/scoped
).
'scope
is the lifetime which data captured in execute
or recurse
closures must outlive - in other words, 'scope
is the maximum lifetime
of all jobs scheduler on a Scope
.
Note that since 'scope: 'scheduler
('scope
outlives 'scheduler
)
&'scheduler Scope<'scope>
can’t be captured in an execute
closure;
this is the reason for the existence of the recurse
API, which will
inject the same scope with a new 'scheduler
lifetime (this time set
to the body of the function passed to recurse
).
Implementations§
Source§impl<'scope> Scope<'scope>
impl<'scope> Scope<'scope>
Sourcepub fn execute<F>(&self, job: F)
pub fn execute<F>(&self, job: F)
Add a job to this scope.
Subsequent calls to join
will wait for this job to complete.
Sourcepub fn recurse<F>(&self, job: F)
pub fn recurse<F>(&self, job: F)
Add a job to this scope which itself will get access to the scope.
Like with execute
, subsequent calls to join
will wait for this
job (and all jobs scheduled on the scope it receives) to complete.