pub struct Scope<'scope, 'env: 'scope> { /* private fields */ }Expand description
A scope to submit closures in.
See scope for details.
Implementations§
Source§impl<'scope, 'env> Scope<'scope, 'env>
impl<'scope, 'env> Scope<'scope, 'env>
Sourcepub fn submit<F: FnOnce() + Send + 'scope>(&'scope self, f: F)
pub fn submit<F: FnOnce() + Send + 'scope>(&'scope self, f: F)
Submits the closure to run on the Pool.
The closure cannot outlive the Scope it’s run in.
Sourcepub fn submit_with_priority<F: FnOnce() + Send + 'scope>(
&'scope self,
priority: Priority,
f: F,
)
pub fn submit_with_priority<F: FnOnce() + Send + 'scope>( &'scope self, priority: Priority, f: F, )
Submits the closure to run on the Pool with the given priority.
The closure cannot outlive the Scope it’s run in.
Methods from Deref<Target = Pool>§
Sourcepub fn set_thread_limits(&self, min: u32, max: u32)
pub fn set_thread_limits(&self, min: u32, max: u32)
Sets the thread limits for the Pool object.
Sourcepub fn submit<F: FnOnce() + Send + 'static>(&self, f: F)
pub fn submit<F: FnOnce() + Send + 'static>(&self, f: F)
Submits a closure to the thread pool.
The closure must be Send + 'static.
Sourcepub fn submit_with_priority<F: FnOnce() + Send + 'static>(
&self,
priority: Priority,
f: F,
)
pub fn submit_with_priority<F: FnOnce() + Send + 'static>( &self, priority: Priority, f: F, )
Submits a closure to the thread pool with the given priority.
The closure must be Send + 'static.
Sourcepub fn scope<'env, F>(&self, f: F)
pub fn scope<'env, F>(&self, f: F)
Create a scope for submitting closures.
Within this scope local variables can be sent to the pool thread for execution.
This is possible because scope will wait for all submitted closures to finish before
returning. It also waits for closures submitted to the same Pool from other threads,
not just those submitted within this scope.