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.
impl EngineWorkerPool
Unified persistent work-stealing thread pool operations for EngineWorkerPool.
Sourcepub fn new() -> Self
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.
Sourcepub fn with_total_threads(total_threads: usize) -> Self
pub fn with_total_threads(total_threads: usize) -> Self
Sourcepub fn worker_count(&self) -> usize
pub fn worker_count(&self) -> usize
Returns the count of active background worker threads excluding the calling thread.
§Returns
usize- Background worker thread count (0on single-core orwasm32).
Sourcepub fn total_threads(&self) -> usize
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.
Sourcepub fn set_spin_active(&self, active: bool)
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-truewhen high-frequency frames are active;falsefor immediate idle parking.
Sourcepub fn spin_limit(&self) -> u32
pub fn spin_limit(&self) -> u32
Returns the active adaptive spin-loop iteration limit configured on this pool.
§Returns
u32- Active spin iteration count.
Sourcepub fn parallel_for_chunks<WorkFn>(
&self,
total_items: usize,
grain_size: usize,
work_fn: WorkFn,
)
pub fn parallel_for_chunks<WorkFn>( &self, total_items: usize, grain_size: usize, work_fn: WorkFn, )
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).
Sourcepub fn parallel_work_steal<ItemType, WorkFn>(
&self,
items: &[ItemType],
work_fn: WorkFn,
)
pub fn parallel_work_steal<ItemType, WorkFn>( &self, items: &[ItemType], work_fn: WorkFn, )
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
impl Debug for EngineWorkerPool
Source§impl Default for EngineWorkerPool
Default construction creating a host-sized EngineWorkerPool.
impl Default for EngineWorkerPool
Default construction creating a host-sized EngineWorkerPool.