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
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 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.
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MorselScheduler
impl !RefUnwindSafe for MorselScheduler
impl Send for MorselScheduler
impl Sync for MorselScheduler
impl Unpin for MorselScheduler
impl !UnwindSafe for MorselScheduler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more