10 releases

Uses old Rust 2015

0.1.9 Feb 20, 2018
0.1.8 Sep 28, 2017
0.1.7 Feb 18, 2016
0.1.6 Aug 24, 2015

#202 in Caching

Download history 45505/week @ 2025-10-11 45307/week @ 2025-10-18 42875/week @ 2025-10-25 55320/week @ 2025-11-01 42275/week @ 2025-11-08 51461/week @ 2025-11-15 48749/week @ 2025-11-22 49982/week @ 2025-11-29 42981/week @ 2025-12-06 38458/week @ 2025-12-13 25094/week @ 2025-12-20 18799/week @ 2025-12-27 34314/week @ 2026-01-03 48079/week @ 2026-01-10 39958/week @ 2026-01-17 46359/week @ 2026-01-24

172,140 downloads per month
Used in 180 crates (64 directly)

MIT license

19KB
355 lines

scoped-threadpool-rs

Travis-CI Status

A library for scoped and cached threadpools.

For more details, see the docs.

Getting Started

scoped-threadpool-rs is available on crates.io. Add the following dependency to your Cargo manifest to get the latest version of the 0.1 branch:

[dependencies]

scoped_threadpool = "0.1.*"

To always get the latest version, add this git repository to your Cargo manifest:

[dependencies.scoped_threadpool]
git = "https://github.com/Kimundi/scoped-threadpool-rs"

Example

extern crate scoped_threadpool;
use scoped_threadpool::Pool;

fn main() {
    // Create a threadpool holding 4 threads
    let mut pool = Pool::new(4);

    let mut vec = vec![0, 1, 2, 3, 4, 5, 6, 7];

    // Use the threads as scoped threads that can
    // reference anything outside this closure
    pool.scoped(|scoped| {
        // Create references to each element in the vector ...
        for e in &mut vec {
            // ... and add 1 to it in a seperate thread
            scoped.execute(move || {
                *e += 1;
            });
        }
    });

    assert_eq!(vec, vec![1, 2, 3, 4, 5, 6, 7, 8]);
}

No runtime deps