#thread-pool #built #crossbeam #work-stealing

zeet

Work-stealing thread pool built on crossbeam

1 unstable release

0.1.0 Dec 3, 2024

#3 in #work-stealing

Download history 95/week @ 2024-11-27 72/week @ 2024-12-04 6/week @ 2024-12-11

173 downloads per month

MIT/Apache

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