ParallelForEachMut

Struct ParallelForEachMut 

Source
pub struct ParallelForEachMut<V, F, I>
where I: AtomicIterator<AtomicItem = V> + Send + Sized, F: FnMut(V), V: Send,
{ pub iter: TaskQueue<I, V>, pub f: F, pub num_threads: usize, pub v: PhantomData<V>, }
Expand description

ParallelForEachMut is a structure type that captures the information necessary to run a FnMut closure within the Iterator in parallel Its the result of parallel_task that can be run on any Iterator implementing type.

 use parallel_task::{for_each_mut::ParallelForEachMutIter, prelude::*};
 
 let mut test = 0;
 let target = 100;
 (0..=target).collect::<Vec<i32>>().
 parallel_iter().for_each_mut(|v| { test += v;});
 assert_eq!(test, (target * (target + 1)/2));

Fields§

§iter: TaskQueue<I, V>§f: F§num_threads: usize§v: PhantomData<V>

Implementations§

Source§

impl<I, V, F> ParallelForEachMut<V, F, I>
where I: AtomicIterator<AtomicItem = V> + Send + Sized, F: FnMut(V) + Send, V: Send,

Source

pub fn new(iter: I, f: F) -> Self

Source

pub fn threads(self, nthreads: usize) -> Self

Set the thread pool size for running the parallel tasker

Source

pub fn run(self)

Auto Trait Implementations§

§

impl<V, F, I> Freeze for ParallelForEachMut<V, F, I>
where F: Freeze, I: Freeze,

§

impl<V, F, I> RefUnwindSafe for ParallelForEachMut<V, F, I>

§

impl<V, F, I> Send for ParallelForEachMut<V, F, I>
where F: Send,

§

impl<V, F, I> Sync for ParallelForEachMut<V, F, I>
where F: Sync, I: Sync, V: Sync,

§

impl<V, F, I> Unpin for ParallelForEachMut<V, F, I>
where F: Unpin, I: Unpin, V: Unpin,

§

impl<V, F, I> UnwindSafe for ParallelForEachMut<V, F, I>
where F: UnwindSafe, I: UnwindSafe, V: UnwindSafe,

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.