PoolScope

Struct PoolScope 

Source
pub struct PoolScope<'a, P: ThreadPool> { /* private fields */ }
Expand description

Scoped execution context for a thread pool.

This provides a convenient way to run operations with a specific thread pool.

Implementations§

Source§

impl<'a, P: ThreadPool> PoolScope<'a, P>

Source

pub fn new(pool: &'a P) -> Self

Creates a new pool scope with default threshold.

Source

pub fn with_threshold(pool: &'a P, threshold: ParThreshold) -> Self

Creates a new pool scope with a custom threshold.

Source

pub fn num_threads(&self) -> usize

Returns the number of threads in the pool.

Source

pub fn join<A, B, RA, RB>(&self, a: A, b: B) -> (RA, RB)
where A: FnOnce() -> RA + Send, B: FnOnce() -> RB + Send, RA: Send, RB: Send,

Joins two closures.

Source

pub fn for_each<F>(&self, total: usize, f: F)
where F: Fn(usize) + Send + Sync,

Parallel for_each over a range.

Source

pub fn for_each_range<F>(&self, total: usize, f: F)
where F: Fn(WorkRange) + Send + Sync,

Parallel for_each over work ranges.

Source

pub fn map_reduce<T, Map, Reduce>( &self, total: usize, identity: T, map: Map, reduce: Reduce, ) -> T
where T: Clone + Send + Sync, Map: Fn(usize) -> T + Send + Sync, Reduce: Fn(T, T) -> T + Send + Sync,

Parallel map-reduce operation.

Auto Trait Implementations§

§

impl<'a, P> Freeze for PoolScope<'a, P>

§

impl<'a, P> RefUnwindSafe for PoolScope<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for PoolScope<'a, P>

§

impl<'a, P> Sync for PoolScope<'a, P>

§

impl<'a, P> Unpin for PoolScope<'a, P>

§

impl<'a, P> UnwindSafe for PoolScope<'a, P>
where P: RefUnwindSafe,

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.