pub struct Pool(/* private fields */);Expand description
A Pool object represents a private thread pool with its own thread limits.
This is in contrast to the default, or shared, thread pool used by the crate’s submit function
as well as other code within the same process.
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn with_scope<'env, F>(f: F)
pub fn with_scope<'env, F>(f: F)
Convenience function for creating a new pool and calling scope.
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.