Crate jobpool [] [src]

A simple, lightweight, and fixed-size threadpool implementation.

Getting started

Add the following under [dependencies] on Cargo.toml:

jobpool = "*" # or a specific version from crates.io

Add the following to the root crate:

extern crate jobpool;

Usage

use jobpool::JobPool;

let pool_size: usize = 8; // number of cpu cores is recommended
let mut pool = JobPool::new(pool_size);
pool.queue(|| {
    // do some work
});
// ...
pool.shutdown(); // waits for jobs to finish

Structs

JobPool

JobPool manages a job queue to be run on a specified number of threads.

Traits

Runnable

A trait for giving a type an ability to run some code.