Trait ConcurrentSlice

Source
pub trait ConcurrentSlice<T> {
    // Provided methods
    fn concurrent_split_at(
        self,
        index: usize,
    ) -> (Chunk<Self, T>, Chunk<Self, T>)
       where Self: 'static + AsMut<[T]> + Sized + Send,
             T: 'static + Send { ... }
    fn concurrent_chunks(self, chunk_size: usize) -> Chunks<Self, T> 
       where Self: 'static + AsMut<[T]> + Sized + Send,
             T: 'static + Send { ... }
    fn concurrent_chunks_by_division(
        self,
        division: impl Into<Option<usize>>,
    ) -> Chunks<Self, T> 
       where Self: 'static + AsMut<[T]> + Sized + Send,
             T: 'static + Send { ... }
    fn owning_iter(self) -> Iter<Self, T> 
       where Self: 'static + Send + Deref + CloneStableAddress,
             Self::Target: AsRef<[T]> { ... }
    fn owning_windows(self, size: usize) -> Windows<Self, T> 
       where Self: 'static + Send + Deref + CloneStableAddress,
             Self::Target: AsRef<[T]> { ... }
}
Expand description

The trait adds methods for concurrent processing on any type that can be borrowed as a slice.

Provided Methods§

Source

fn concurrent_split_at(self, index: usize) -> (Chunk<Self, T>, Chunk<Self, T>)
where Self: 'static + AsMut<[T]> + Sized + Send, T: 'static + Send,

Splits the slice-like data into two sub-slices, divided at specified index.

§Panics

The method panics if the index is out of bound.

Source

fn concurrent_chunks(self, chunk_size: usize) -> Chunks<Self, T>
where Self: 'static + AsMut<[T]> + Sized + Send, T: 'static + Send,

Returns an iterator of roughly fixed-sized chunks of the slice.

Each chunk has chunk_size elements, expect the last chunk maybe shorter if there aren’t enough elements.

The yielded chunks maintain a global reference count. Each chunk refers to a mutable and exclusive sub-slice, enabling concurrent processing on input data.

§Panics

The method panics if chunk_size is zero and slice length is not zero.

Source

fn concurrent_chunks_by_division( self, division: impl Into<Option<usize>>, ) -> Chunks<Self, T>
where Self: 'static + AsMut<[T]> + Sized + Send, T: 'static + Send,

Returns an iterator with roughly division length of roughly fixed-sized chunks of the slice.

The chunk size is determined by division. The last chunk maybe shorter if there aren’t enough elements. If division is None, it defaults to the number of system processors.

§Panics

The method panics if division is zero and slice length is not zero.

Source

fn owning_iter(self) -> Iter<Self, T>
where Self: 'static + Send + Deref + CloneStableAddress, Self::Target: AsRef<[T]>,

Returns an iterator of owned references to each element of the slice.

Source

fn owning_windows(self, size: usize) -> Windows<Self, T>
where Self: 'static + Send + Deref + CloneStableAddress, Self::Target: AsRef<[T]>,

Returns an iterator of owned windows of length size. The windows are contiguous and overlap. If the slice is shorter than size, the iterator returns no values.

Implementors§

Source§

impl<S, T> ConcurrentSlice<T> for S