10 个版本

使用旧的 Rust 2015

0.1.9 2018 年 2 月 20 日
0.1.8 2017 年 9 月 28 日
0.1.7 2016 年 2 月 18 日
0.1.6 2015 年 8 月 24 日

#277 in 并发

Download history · Rust 包仓库 52888/week @ 2023-10-22 · Rust 包仓库 57048/week @ 2023-10-29 · Rust 包仓库 59041/week @ 2023-11-05 · Rust 包仓库 71429/week @ 2023-11-12 · Rust 包仓库 56607/week @ 2023-11-19 · Rust 包仓库 61139/week @ 2023-11-26 · Rust 包仓库 54710/week @ 2023-12-03 · Rust 包仓库 50692/week @ 2023-12-10 · Rust 包仓库 52217/week @ 2023-12-17 · Rust 包仓库 19311/week @ 2023-12-24 · Rust 包仓库 37660/week @ 2023-12-31 · Rust 包仓库 45324/week @ 2024-01-07 · Rust 包仓库 43983/week @ 2024-01-14 · Rust 包仓库 51873/week @ 2024-01-21 · Rust 包仓库 53854/week @ 2024-01-28 · Rust 包仓库 46287/week @ 2024-02-04 · Rust 包仓库

198,417 个月下载量
用于 少于 57 crates

MIT 许可证

19KB
355

scoped-threadpool-rs

Travis-CI Status

用于范围和缓存的线程池库。

更多详细信息,请参阅文档

入门

scoped-threadpool-rs 在 crates.io 上可用。将以下依赖项添加到您的 Cargo 清单中,以获取 0.1 分支的最新版本

[dependencies]

scoped_threadpool = "0.1.*"

要始终获取最新版本,请将此 git 仓库添加到您的 Cargo 清单

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

示例

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]);
}

无运行时依赖