Skip to main content

Runner

Struct Runner 

Source
pub struct Runner;
Expand description

Entry point for creating parallel runners that control how work is distributed across threads.

A runner is passed to .runner(...) on a parallel iterator to select the execution strategy.

Note: Runner is a convenience factory for the runners provided by this crate. You can also implement a compatible runner type yourself and pass it directly to .runner(...) — the transformation accepts any type that satisfies the trait.

§Examples

use orx_parallel::*;

let par = (0..100).par().map(|x| x + 1);
let par = par.runner(Runner::fixed());
let sum = par.sum();

let par = (0..100).par().map(|x| x + 1);
#[cfg(feature = "std")]
let par = par.runner(Runner::adaptive());
let sum = par.sum();

Implementations§

Source§

impl Runner

Source

pub fn fixed() -> FixedChunkRunner<DefaultPool>

Creates a runner that splits work into fixed-size chunks ahead of time.

This is the default strategy: the input is divided into equal chunks, one per thread. It has low overhead and works well when tasks have uniform cost.

§Example
use orx_parallel::*;

let par = (0..100).par().map(|x| x + 1);
let par = par.runner(Runner::fixed());

let result: Vec<_> = par.collect();
Source

pub fn fixed_with_pool<P: ThreadPool>(pool: P) -> FixedChunkRunner<P>

Creates a fixed chunk runner backed by pool.

Use this when a computation should use a specific thread pool instead of the global default pool. The returned runner keeps the fixed-size chunking strategy of Self::fixed while delegating execution to the provided pool.

§Example
use orx_parallel::*;

let par = (0..100).par();

#[cfg(feature = "std")]
let par = par.runner(Runner::fixed_with_pool(Pool::basic(4)));

let result: Vec<_> = par.collect();
Source

pub fn adaptive() -> AdaptiveChunkRunner<DefaultPool>

Creates an adaptive chunk runner.

This strategy explores and selects chunk sizes based on observed runtime behavior.

§Example
use orx_parallel::*;

let par = (0..100).par().map(|x| x + 1);

#[cfg(feature = "std")]
let par = par.runner(Runner::adaptive());

let result: Vec<_> = par.collect();
Source

pub fn adaptive_with_pool<P: ThreadPool>(pool: P) -> AdaptiveChunkRunner<P>

Creates an adaptive chunk runner backed by pool.

Use this when a computation should combine a specific thread pool with adaptive chunk sizing. The returned runner keeps the adaptive strategy of Self::adaptive while delegating execution to the provided pool.

§Example
use orx_parallel::*;

let pool = Pool::once(4);
let par = (0..100).par().runner(Runner::adaptive_with_pool(pool));

let result: Vec<_> = par.collect();

Auto Trait Implementations§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

fn get_mut(&mut self) -> &mut T

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.