Skip to main content

EngineWorkerPool

Struct EngineWorkerPool 

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

Persistent zero-dependency work-stealing thread pool shared by parallel CPU layout, paint packing, and software rasterization.

Implementations§

Source§

impl EngineWorkerPool

Unified persistent work-stealing thread pool operations for EngineWorkerPool.

Source

pub fn new() -> Self

Creates a new persistent worker pool sized to the host hardware concurrency (1..=ENGINE_WORKER_MAX_THREADS).

§Returns
  • Self - Initialized worker pool with warm background threads.
Source

pub fn with_total_threads(total_threads: usize) -> Self

Creates a persistent worker pool configured for total_threads concurrent execution lanes (caller plus background workers).

§Arguments
  • usize - Desired total thread count clamped to 1..=ENGINE_WORKER_MAX_THREADS.
§Returns
  • Self - Initialized worker pool.
Source

pub fn worker_count(&self) -> usize

Returns the count of active background worker threads excluding the calling thread.

§Returns
  • usize - Background worker thread count (0 on single-core or wasm32).
Source

pub fn total_threads(&self) -> usize

Returns total concurrent execution threads including the calling thread (1..=ENGINE_WORKER_MAX_THREADS).

§Returns
  • usize - Total execution thread count.
Source

pub fn set_spin_active(&self, active: bool)

Updates the adaptive hybrid spin limit on this pool (ENGINE_WORKER_SPIN_LIMIT_ACTIVE vs ENGINE_WORKER_SPIN_LIMIT_IDLE).

§Arguments
  • bool - true when high-frequency frames are active; false for immediate idle parking.
Source

pub fn spin_limit(&self) -> u32

Returns the active adaptive spin-loop iteration limit configured on this pool.

§Returns
  • u32 - Active spin iteration count.
Source

pub fn parallel_for_chunks<WorkFn>( &self, total_items: usize, grain_size: usize, work_fn: WorkFn, )
where WorkFn: Fn(usize, usize, usize) + Sync,

Partitions [0..total_items) into grain_size chunks claimed lock-free across workers and executes work_fn(start, end, worker_lane).

§Arguments
  • usize - Total number of logical items to process.
  • usize - Minimum items per claimed work-stealing chunk (>= 1).
  • WorkFn - Synchronized closure receiving (chunk_start, chunk_end, worker_lane_index).
Source

pub fn parallel_work_steal<ItemType, WorkFn>( &self, items: &[ItemType], work_fn: WorkFn, )
where ItemType: Sync, WorkFn: Fn(usize, &ItemType, usize) + Sync,

Executes work_fn(index, item, worker_lane) for every element in items using lock-free atomic work-stealing.

§Arguments
  • &[ItemType] - Contiguous slice of work items to distribute across workers.
  • WorkFn - Synchronized closure receiving (item_index, item_ref, worker_lane_index).

Trait Implementations§

Source§

impl Debug for EngineWorkerPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EngineWorkerPool

Default construction creating a host-sized EngineWorkerPool.

Source§

fn default() -> Self

Creates a default host-sized EngineWorkerPool.

§Returns
  • Self - Host-sized persistent worker pool.
Source§

impl Drop for EngineWorkerPool

Available on non-WebAssembly only.

Clean background thread shutdown and handle join when an EngineWorkerPool drops.

Source§

fn drop(&mut self)

Signals all persistent background worker threads to exit and joins every handle.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for EngineWorkerPool

§

impl !RefUnwindSafe for EngineWorkerPool

§

impl !UnwindSafe for EngineWorkerPool

§

impl Forget for EngineWorkerPool

§

impl Move for EngineWorkerPool

§

impl Send for EngineWorkerPool
where Mutex<()>: Send, Arc<EnginePoolShared>: Send, RawVecInner: Send, JoinHandle<()>: Send,

§

impl Sync for EngineWorkerPool
where Mutex<()>: Sync, Arc<EnginePoolShared>: Sync, RawVecInner: Sync, JoinHandle<()>: Sync,

§

impl Unpin for EngineWorkerPool
where Align4<u32>: Unpin, Align1<u8>: Unpin, Arc<EnginePoolShared>: Unpin, *const u8 is !null: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin,

§

impl UnsafeUnpin for EngineWorkerPool
where Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const ArcInner<EnginePoolShared> is !null: UnsafeUnpin, PhantomData<ArcInner<EnginePoolShared>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<JoinHandle<()>>: UnsafeUnpin,

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 = !

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.