pub struct MorselScheduler { /* private fields */ }Expand description
Work-stealing morsel scheduler.
Distributes morsels to worker threads efficiently:
- Workers check the global injector queue
- If empty, steal from other workers via stealers
Supports NUMA-aware stealing to minimize cross-node memory access.
Implementations§
Source§impl MorselScheduler
impl MorselScheduler
Sourcepub fn new(num_workers: usize) -> Self
pub fn new(num_workers: usize) -> Self
Creates a new scheduler for the given number of workers.
Sourcepub fn with_numa_config(num_workers: usize, numa_config: NumaConfig) -> Self
pub fn with_numa_config(num_workers: usize, numa_config: NumaConfig) -> Self
Creates a scheduler with explicit NUMA configuration.
Sourcepub fn num_workers(&self) -> usize
pub fn num_workers(&self) -> usize
Returns the number of workers.
Sourcepub fn submit_batch(&self, morsels: Vec<Morsel>)
pub fn submit_batch(&self, morsels: Vec<Morsel>)
Submits multiple morsels to the global queue.
Sourcepub fn finish_submission(&self)
pub fn finish_submission(&self)
Signals that no more morsels will be submitted.
Sourcepub fn register_worker(&self, stealer: Stealer<Morsel>) -> usize
pub fn register_worker(&self, stealer: Stealer<Morsel>) -> usize
Registers a worker’s stealer for work-stealing.
Returns the worker_id assigned.
Sourcepub fn get_global_work(&self) -> Option<Morsel>
pub fn get_global_work(&self) -> Option<Morsel>
Gets work from the global queue.
Sourcepub fn steal_work(&self, my_id: usize) -> Option<Morsel>
pub fn steal_work(&self, my_id: usize) -> Option<Morsel>
Tries to steal work from other workers.
Uses NUMA-aware stealing: prefers workers on the same NUMA node to minimize cross-node memory access latency.
Sourcepub fn worker_node(&self, worker_id: usize) -> NumaNode
pub fn worker_node(&self, worker_id: usize) -> NumaNode
Returns the NUMA node for a worker.
Sourcepub fn complete_morsel(&self)
pub fn complete_morsel(&self)
Marks a morsel as completed.
Must be called after processing each morsel.
Sourcepub fn is_submission_done(&self) -> bool
pub fn is_submission_done(&self) -> bool
Returns whether submission is complete.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of active (in-progress) morsels.
Sourcepub fn total_submitted(&self) -> usize
pub fn total_submitted(&self) -> usize
Returns the total number of morsels submitted.