Pool

Struct Pool 

Source
pub struct Pool { /* private fields */ }
Expand description

Holds a number of threads that you can run tasks on

Implementations§

Source§

impl Pool

Source

pub fn new() -> Pool

Spawn a pool with the native number of threads and a fixed backlog

The native number of threads is the number of logical cpus according to the crate num_cpus

The backlog, 4 times the number of threads, is the number of unprocessed jobs that are allowed to accumulate from Scope::execute

Source

pub fn unbounded() -> Pool

Spawn a pool with the native number of threads an un unbounded backlog

The native number of threads is the number of logical cpus according to the crate num_cpus

Scope::execute will never block and will accumulate any task you give it. This may require a lot of memory.

Source

pub fn new_threads(nthreads: usize, backlog: usize) -> Pool

Spawn a number of threads. The pool’s queue of pending jobs is limited.

backlog is the number of jobs that haven’t been run. If specified, Scope::execute will block until a job completes.

Source

pub fn new_threads_unbounded(nthreads: usize) -> Pool

Spawn a number of threads. The pool’s queue of pending jobs is limited.

the backlog is unbounded as in unbounded.

Source

pub fn scoped<'pool, 'scope, F>(&'pool mut self, f: F)
where F: FnOnce(Scope<'pool, 'scope>),

Store the current scope so that you can run jobs in it.

This function panics if the given closure or any threads panic.

Does not return until all executed jobs complete.

Trait Implementations§

Source§

impl Drop for Pool

Source§

fn drop(&mut self)

terminates all threads

Auto Trait Implementations§

§

impl Freeze for Pool

§

impl !RefUnwindSafe for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl !UnwindSafe for Pool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.