Trait dpc_pariter::IteratorExt[][src]

pub trait IteratorExt {
    fn parallel_map<F, O>(self, f: F) -> ParallelMap<Self, O, F, ThreadPool>
Notable traits for ParallelMap<I, O, F, TP>
impl<I, O, F, TP> Iterator for ParallelMap<I, O, F, TP> where
    I: Iterator,
    I::Item: Send + 'static,
    O: Send + 'static,
    TP: ThreadPool,
    F: FnMut(I::Item) -> O,
    F: Clone + Send + 'static, 
type Item = O;

    where
        Self: Sized,
        Self: Iterator,
        F: FnMut(Self::Item) -> O
;
fn parallel_filter<F>(self, f: F) -> ParallelFilter<Self, ThreadPool>
Notable traits for ParallelFilter<I, TP>
impl<I, TP> Iterator for ParallelFilter<I, TP> where
    I: Iterator,
    I::Item: Send + 'static,
    TP: ThreadPool
type Item = I::Item;

    where
        Self: Sized,
        Self: Iterator + Send,
        F: FnMut(&Self::Item) -> bool + Send + 'static + Clone,
        Self::Item: Send + 'static
;
fn readahead(self, buffer_size: usize) -> Readahead<Self, ThreadPool>
Notable traits for Readahead<I, TP>
impl<I, TP> Iterator for Readahead<I, TP> where
    I: Iterator,
    TP: ThreadPool,
    I: Send + 'static,
    I::Item: Send + 'static, 
type Item = I::Item;

    where
        Self: Iterator,
        Self: Sized,
        Self: Send + 'static,
        Self::Item: Send + 'static
; }
Expand description

Extension trait for std::iter::Iterator bringing parallel operations

TODO

  • parallel_for_each
  • parallel_flat_map
  • possibly others

PRs welcome

Required methods

Run map function in parallel on multiple threads

Results will be returned in order.

No worker threads will be started and no items will be pulled unless ParallelMap::started was called, or until first time ParallelMap is pulled for elements with ParallelMap::next. In that respect, ParallelMap behaves like every other iterator and is lazy.

Default built-in thread pool will be used unless ParallelMap::threads is used.

Run filter function in parallel on multiple threads

A wrapper around IteratorExt::parallel_map really, so it has similiar properties.

Run the current iterator in another thread and return elements through a buffered channel.

buffer_size defines the size of the output channel connecting current and the inner thread. It’s a common mistake to use large channel sizes needlessly in hopes of achieving higher performance. The only benefit large buffer size value provides is smooting out the variance of the inner iterator. The cost - wasting memory. In normal circumstances 0 is recommended.

Implementors