Struct scoped_threadpool::Pool
source · pub struct Pool { /* private fields */ }
Expand description
A threadpool that acts as a handle to a number of threads spawned at construction.
Implementations§
source§impl Pool
impl Pool
sourcepub fn new(n: u32) -> Pool
pub fn new(n: u32) -> Pool
Construct a threadpool with the given number of threads.
Minimum value is 1
.
sourcepub fn scoped<'pool, 'scope, F, R>(&'pool mut self, f: F) -> Rwhere
F: FnOnce(&Scope<'pool, 'scope>) -> R,
pub fn scoped<'pool, 'scope, F, R>(&'pool mut self, f: F) -> Rwhere F: FnOnce(&Scope<'pool, 'scope>) -> R,
Borrows the pool and allows executing jobs on other threads during that scope via the argument of the closure.
This method will block until the closure and all its jobs have run to completion.
sourcepub fn thread_count(&self) -> u32
pub fn thread_count(&self) -> u32
Returns the number of threads inside this pool.