Skip to main content

RingExecutor

Struct RingExecutor 

Source
pub struct RingExecutor { /* private fields */ }
Expand description

A hardware-shaped pool of worker threads draining an unbounded set of tasks through per-worker SubEtha ready-ring shards.

Implementations§

Source§

impl RingExecutor

Source

pub fn with_available_parallelism(max_tasks: usize) -> Self

Build an executor whose worker count matches the host’s logical core count (std::thread::available_parallelism). The ready queue gets one shard per worker; max_tasks is the peak number of simultaneously-live tasks the queue must hold.

Source

pub fn new(n_workers: usize, max_tasks: usize) -> Self

Build an executor with n_workers worker threads (one ready shard each) and a ready queue sized to hold at least max_tasks simultaneously-live task handles, spread across the shards.

Source

pub fn spawn(&self, future: impl Future<Output = ()> + Send + 'static)

Spawn a future. It runs to completion on the pool, suspending (off-thread) whenever it awaits, with no thread dedicated to it.

Source

pub fn pending(&self) -> usize

Number of tasks not yet complete.

Source

pub fn worker_count(&self) -> usize

Number of worker threads (one ready shard each).

Source

pub fn shard_count(&self) -> usize

Number of ready-ring shards (equals worker count).

Source

pub fn pinned_workers(&self) -> usize

How many workers were pinned to a distinct core (best-effort; 0 on hosts without an affinity API). Read after the workers have started.

Source

pub fn shard_capacity(&self) -> usize

Per-shard slot capacity (power of two).

Source

pub fn wait_idle(&self)

Spin until every spawned task has completed.

Source

pub fn shutdown(self)

Stop the workers (after the rings drain) and join them. Call once the spawned work has completed.

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, 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.