Crate jobpool [] [src]

A simple and lightweight 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.auto_grow(100);

for _ in 0..1000 {
    pool.queue(|| {
        // do some work
    });
    // or pool.queue_with_priority(move || {...}, priority_val);
}
// ...
pool.shutdown(); // waits for jobs to finish

Structs

JobPool

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

Constants

NORMAL_PRIORITY

A constant reference value for normal priority.

Traits

Runnable

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