scoped_threadpool

Crates.ioscoped_threadpool
lib.rsscoped_threadpool
version0.1.9
sourcesrc
created_at2015-08-22 13:43:25.266977
updated_at2018-02-20 21:53:55.075569
descriptionA library for scoped and cached threadpools.
homepage
repositoryhttps://github.com/Kimundi/scoped-threadpool-rs
max_upload_size
id2895
size24,006
Marvin Löbel (Kimundi)

documentation

http://kimundi.github.io/scoped-threadpool-rs/scoped_threadpool/index.html

README

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]);
}
Commit count: 45

cargo fmt