1 unstable release
0.1.0 | Dec 3, 2024 |
---|
#3 in #work-stealing
173 downloads per month
13KB
284 lines
zeet
Work-stealing thread pool built on crossbeam
.
Example
use zeet::WorkStealThreadPool;
use std::sync::mpsc;
fn main() {
let thread_count = num_cpus::get();
let tp = WorkStealThreadPool::builder()
.max_threads(thread_count.try_into().unwrap())
.build();
let (tx, rx) = mpsc::channel();
for _ in 0..thread_count {
let tx = tx.clone();
tp.spawn(move || {
tx.send(1).unwrap();
});
}
assert_eq!(rx.iter().take(thread_count).sum::<usize>(), thread_count);
tp.join().unwrap();
}
Dependencies
~1–6MB
~34K SLoC