ParallelMap

Struct ParallelMap 

Source
pub struct ParallelMap<V, F, T, I>
where I: AtomicIterator<AtomicItem = V> + Send + Sized, F: Fn(V) -> T + Send, V: Send, T: Send,
{ pub iter: TaskQueue<I, V>, pub f: Pin<Box<F>>, pub num_threads: usize, pub v: PhantomData<V>, pub t: PhantomData<T>, }

Fields§

§iter: TaskQueue<I, V>§f: Pin<Box<F>>§num_threads: usize§v: PhantomData<V>§t: PhantomData<T>

Implementations§

Source§

impl<I, V, F, T> ParallelMap<V, F, T, I>
where I: AtomicIterator<AtomicItem = V> + Send + Sized, F: Fn(V) -> T + Send, V: Send, T: Send,

ParallelMap is a object that allows map function to be run on AtomicIterators. The results may be then collected in types implementing Collector trait.

use parallel_task::prelude::*;
 
let res = (0..100_000).collect::<Vec<i32>>().parallel_iter().map(|val|*val).collect::<Vec<i32>>();
assert_eq!(res.len(),100_000)
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 collect<C>(self) -> C
where C: Collector<T>,

Collect the results of the Map in a type implementing Collector trait

Auto Trait Implementations§

§

impl<V, F, T, I> Freeze for ParallelMap<V, F, T, I>
where I: Freeze,

§

impl<V, F, T, I> RefUnwindSafe for ParallelMap<V, F, T, I>

§

impl<V, F, T, I> Send for ParallelMap<V, F, T, I>

§

impl<V, F, T, I> Sync for ParallelMap<V, F, T, I>
where I: Sync, V: Sync, T: Sync, F: Sync,

§

impl<V, F, T, I> Unpin for ParallelMap<V, F, T, I>
where I: Unpin, V: Unpin, T: Unpin,

§

impl<V, F, T, I> UnwindSafe for ParallelMap<V, F, T, I>

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.