Trait ThreadRunner

Source
pub trait ThreadRunner: Sized {
    type SharedState;

    // Required methods
    fn next_chunk_size<I>(
        &self,
        shared_state: &Self::SharedState,
        iter: &I,
    ) -> usize
       where I: ConcurrentIter;
    fn begin_chunk(&mut self, chunk_size: usize);
    fn complete_chunk(
        &mut self,
        shared_state: &Self::SharedState,
        chunk_size: usize,
    );
    fn complete_task(&mut self, shared_state: &Self::SharedState);
}
Expand description

Thread runner responsible for executing the tasks assigned to the thread by the parallel runner.

Required Associated Types§

Source

type SharedState

Type of the shared state among threads.

Required Methods§

Source

fn next_chunk_size<I>( &self, shared_state: &Self::SharedState, iter: &I, ) -> usize
where I: ConcurrentIter,

Returns the next chunks size to be pulled from the input iter for the given current shared_state.

Source

fn begin_chunk(&mut self, chunk_size: usize)

Hook that will be called before starting to execute the chunk of the given chunk_size.

Source

fn complete_chunk( &mut self, shared_state: &Self::SharedState, chunk_size: usize, )

Hook that will be called after completing the chunk of the given chunk_size. The shared_state is also provided so that it can be updated to send information to the parallel runner and other thread runners.

Source

fn complete_task(&mut self, shared_state: &Self::SharedState)

Hook that will be called after completing the task. The shared_state is also provided so that it can be updated to send information to the parallel runner and other thread runners.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§