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 52888/week @ 2023-10-22 57048/week @ 2023-10-29 59041/week @ 2023-11-05 71429/week @ 2023-11-12 56607/week @ 2023-11-19 61139/week @ 2023-11-26 54710/week @ 2023-12-03 50692/week @ 2023-12-10 52217/week @ 2023-12-17 19311/week @ 2023-12-24 37660/week @ 2023-12-31 45324/week @ 2024-01-07 43983/week @ 2024-01-14 51873/week @ 2024-01-21 53854/week @ 2024-01-28 46287/week @ 2024-02-04

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

无运行时依赖