Skip to main content

work_steal_queue

Function work_steal_queue 

Source
pub fn work_steal_queue<T: Send + Clone>(
    tasks: Vec<T>,
    num_workers: usize,
    _process: impl Fn(&T) + Sync,
) -> Vec<usize>
Expand description

Simulate a work-stealing dispatcher across num_workers queues.

tasks is divided evenly among workers. Any worker that finishes early steals from the most loaded remaining worker. Returns a Vecusizeof lengthnum_workers` recording the tasks each worker processed.