[−][src]Struct executors::crossbeam_workstealing_pool::ThreadPool
A handle associated with the thread pool structure
Implementations
impl<P> ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,
pub fn new(threads: usize, parker: P) -> ThreadPool<P>
[src]
Creates a new thread pool capable of executing threads
number of jobs concurrently.
Must supply a parker
that can handle the requested number of threads.
Panics
- This function will panic if
threads
is 0. - It will also panic if
threads
is larger than theThreadData::MAX_THREADS
value of the providedparker
.
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_workstealing_pool::ThreadPool; let pool = ThreadPool::new(4, parker::small());
pub fn with_affinity(
cores: &[CoreId],
floating: usize,
parker: P
) -> ThreadPool<P>
[src]
cores: &[CoreId],
floating: usize,
parker: P
) -> ThreadPool<P>
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. - This function will panic if
cores.len() + floating
is greater thanparker.max_threads()
. - This function will panic if no core ids can be accessed.
pub fn with_numa_affinity(
cores: &[CoreId],
floating: usize,
parker: P,
pu_distance: ProcessingUnitDistance
) -> ThreadPool<P>
[src]
cores: &[CoreId],
floating: usize,
parker: P,
pu_distance: ProcessingUnitDistance
) -> ThreadPool<P>
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.
Internally the stealers will use the provided PU distance matrix to prioritise stealing from queues that are "closer" by, in order to try and reduce memory movement across caches and NUMA nodes.
Panics
- This function will panic if
cores.len() + floating
is 0. - This function will panic if
cores.len() + floating
is greater thanparker.max_threads()
. - This function will panic if no core ids can be accessed.
Trait Implementations
impl<P> CanExecute for ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,
fn execute_job(&self, job: Box<dyn FnOnce() + Send + 'static>)
[src]
impl<P: Clone> Clone for ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,
fn clone(&self) -> ThreadPool<P>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<P: Debug> Debug for ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,
impl Default for ThreadPool<DynParker>
[src]
Create a thread pool with one thread per CPU. On machines with hyperthreading, this will create one thread per hyperthread.
impl<P> Executor for ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,
fn shutdown_async(&self)
[src]
fn shutdown_borrowed(&self) -> Result<(), String>
[src]
fn execute<F>(&self, job: F) where
F: FnOnce() + Send + 'static,
[src]
F: FnOnce() + Send + 'static,
fn shutdown(self) -> Result<(), String>
[src]
impl<P> FuturesExecutor for ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,
Auto Trait Implementations
impl<P> !RefUnwindSafe for ThreadPool<P>
impl<P> Send for ThreadPool<P>
impl<P> Sync for ThreadPool<P>
impl<P> Unpin for ThreadPool<P>
impl<P> !UnwindSafe for ThreadPool<P>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,