pub struct ThreadPool { /* private fields */ }Expand description
Thread Pool
A thread pool coordinates a group of threads to run taks in parallel.
§Example
use job_pool::ThreadPool;
let pool = ThreadPool::with_size(32).expect("Error creating pool");
pool.execute(|| println!("Hello world!"));Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn new(config: PoolConfig) -> Result<ThreadPool>
pub fn new(config: PoolConfig) -> Result<ThreadPool>
Create a new ThreadPool.
Sourcepub fn with_default_config() -> Result<Self>
pub fn with_default_config() -> Result<Self>
Create a ThreadPool with the default configuration
Sourcepub fn with_size(size: u16) -> Result<Self>
pub fn with_size(size: u16) -> Result<Self>
Create a ThreadPool with a given size
pub fn execute(&self, job: impl Job)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ThreadPool
impl !RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl !UnwindSafe for ThreadPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more