[][src]Struct executors::crossbeam_workstealing_pool::ThreadPool

pub struct ThreadPool<P> where
    P: Parker + Clone + 'static, 
{ /* fields omitted */ }

A handle associated with the thread pool structure

Implementations

impl<P> ThreadPool<P> where
    P: Parker + Clone + 'static, 
[src]

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 the ThreadData::MAX_THREADS value of the provided parker.

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]

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 than parker.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]

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 than parker.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]

impl<P: Clone> Clone for ThreadPool<P> where
    P: Parker + Clone + 'static, 
[src]

impl<P: Debug> Debug for ThreadPool<P> where
    P: Parker + Clone + 'static, 
[src]

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]

impl<P> FuturesExecutor for ThreadPool<P> where
    P: Parker + Clone + 'static, 
[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,