pub struct ThreadPool { /* private fields */ }Expand description
A handle to a crossbeam_channel_pool
See module level documentation for usage information.
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn new(threads: usize) -> ThreadPool
pub fn new(threads: usize) -> ThreadPool
Creates a new thread pool capable of executing threads number of jobs concurrently.
§Panics
This function will panic if threads is 0.
§Core Affinity
If compiled with thread-pinning it will assign a worker to each cores,
until it runs out of cores or workers. If there are more workers than cores,
the extra workers will be “floating”, i.e. not pinned.
§Examples
Create a new thread pool capable of executing four jobs concurrently:
use executors::*;
use executors::crossbeam_channel_pool::ThreadPool;
let pool = ThreadPool::new(4);Sourcepub fn with_affinity(cores: &[CoreId], floating: usize) -> ThreadPool
pub fn with_affinity(cores: &[CoreId], floating: usize) -> ThreadPool
Creates a new thread pool capable of executing threads number of jobs concurrently with a particular core affinity.
For each core id in the core slice, it will generate a single thread pinned to that id.
Additionally, it will create floating number of unpinned threads.
§Panics
This function will panic if cores.len() + floating is 0.
Trait Implementations§
Source§impl CanExecute for ThreadPool
impl CanExecute for ThreadPool
Source§impl Clone for ThreadPool
impl Clone for ThreadPool
Source§fn clone(&self) -> ThreadPool
fn clone(&self) -> ThreadPool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThreadPool
impl Debug for ThreadPool
Source§impl Default for ThreadPool
Create a thread pool with one thread per CPU.
On machines with hyperthreading,
this will create one thread per hyperthread.
impl Default for ThreadPool
Create a thread pool with one thread per CPU. On machines with hyperthreading, this will create one thread per hyperthread.