Crates.io | zeet |
lib.rs | zeet |
version | 0.1.0 |
source | src |
created_at | 2024-12-03 05:48:50.449777 |
updated_at | 2024-12-03 05:48:50.449777 |
description | Work-stealing thread pool built on crossbeam |
homepage | |
repository | https://github.com/bells307/zeet |
max_upload_size | |
id | 1469686 |
size | 12,717 |
Work-stealing thread pool built on crossbeam
.
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();
}