pub trait ThreadPool {
    // Required methods
    fn new(threads: usize) -> Result<Self>
       where Self: Sized;
    fn spawn<F>(&self, job: F)
       where F: FnOnce() + Send + 'static;
    fn shutdown(self);
}
Expand description

The trait that all thread pools should implement.

Required Methods§

source

fn new(threads: usize) -> Result<Self>where Self: Sized,

Creates a new thread pool, immediately spawning the specified number of threads.

Returns an error if any thread fails to spawn. All previously-spawned threads are terminated.

source

fn spawn<F>(&self, job: F)where F: FnOnce() + Send + 'static,

Spawns a function into the thread pool.

source

fn shutdown(self)

Shuts down the thread pool, waiting for all threads to finish.

Implementors§